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 q5L61
Output for 5.1.3 - 7.2.0
22 22 22
Output for 5.0.2 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/hANUc on line 3 22 22 22
Output for 5.0.0 - 5.0.1
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/hANUc on line 3 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 10 22PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 18 22PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 29 22PHP_EOL
Output for 4.3.10 - 4.4.9
11 22 11
Output for 4.3.0 - 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 10 11PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 18 22PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 29 11PHP_EOL