3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { var $foo = 1; } function update($obj) { $obj->foo = 3; } function replace($obj) { $a = new A; $a->foo = 3; $obj = $a; } function replaceByRef(&$obj) { $a = new A; $a->foo = 3; $obj = $a; } $a = new A; $b = new A; $c = new A; call_user_func_array("update", array(&$a)); call_user_func_array("replace", array(&$b)); call_user_func_array("replaceByRef", array(&$c)); echo $a->foo . "\n"; echo $b->foo . "\n"; echo $c->foo . "\n";
Output for 5.4.0 - 7.3.0rc6
3 1 3
Output for 4.3.0 - 4.4.9, 5.1.3 - 5.3.29
3 3 3
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/3g5cb on line 3 3 3 3