3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { var $foo = 1; } $a = new A; $b = $a; // $a and $b are copies of the same identifier // ($a) = ($b) = <id> $b->foo = 2; echo '$a->foo: ' . $a->foo . PHP_EOL; $c = new A; $d = &$c; // $c and $d are references // ($c,$d) = <id> $d->foo = 2; echo '$c->foo: ' . $c->foo . PHP_EOL; $e = new A; function foo($obj) { // ($obj) = ($e) = <id> $obj->foo = 2; } foo($e); echo '$e->foo: ' . $e->foo . PHP_EOL;
based on K80l5
Output for 5.1.3 - 7.2.0
$a->foo: 2 $c->foo: 2 $e->foo: 2
Output for 5.0.2 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/M66aq on line 3 $a->foo: 2 $c->foo: 2 $e->foo: 2
Output for 5.0.0 - 5.0.1
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/M66aq on line 3 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/M66aq on line 10 $a->foo: 2PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/M66aq on line 18 $c->foo: 2PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/M66aq on line 29 $e->foo: 2PHP_EOL
Output for 4.3.10 - 4.4.9
$a->foo: 1 $c->foo: 2 $e->foo: 1
Output for 4.3.0 - 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/M66aq on line 10 $a->foo: 1PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/M66aq on line 18 $c->foo: 2PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/M66aq on line 29 $e->foo: 1PHP_EOL