3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = new stdClass; $b = $a; $a->foo = 'bar'; var_dump($b); /* Notice at this point, that $a and $b are, * indeed sharing the same object instance. * This is their reference-like behavior at work. */ $a = 'baz'; var_dump($a); var_dump($b); /* Notice now, that $b is still that original object. * Had it been an actual reference with $a, * it would have changed to a simple string as well. */ ?>
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
object(stdClass)#1 (1) { ["foo"]=> string(3) "bar" } string(3) "baz" object(stdClass)#1 (1) { ["foo"]=> string(3) "bar" }
Output for 4.3.0 - 4.4.9
object(stdClass)(0) { } string(3) "baz" object(stdClass)(0) { }