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."\n"; $c = new A; $d = &$c; // $c and $d are references // ($c,$d) = <id> $d->foo = 2; echo $c->foo."\n"; $e = new A; function foo($obj) { // ($obj) = ($e) = <id> $obj->foo = 2; } foo($e); echo $e->foo."\n";
based on C3YvZ
Output for 5.1.3 - 7.2.0
2 2 2
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/q5L61 on line 3 2 2 2
Output for 4.3.0 - 4.4.9
1 2 1