3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class c { function __wakeup() { $this->prop = 'I am awake'; } } $a = []; $a[] = new c; $a[0]->prop = 'asleep'; $a[1] =& $a[0]->prop; var_dump(unserialize(serialize($a)));
based on sRfqe
Output for 7.0.0 - 7.2.0
array(2) { [0]=> object(c)#2 (1) { ["prop"]=> &string(10) "I am awake" } [1]=> &string(10) "I am awake" }
Output for 5.4.39 - 5.6.28
array(2) { [0]=> object(c)#2 (1) { ["prop"]=> string(10) "I am awake" } [1]=> string(6) "asleep" }
Output for 5.4.12 - 5.4.38
array(2) { [0]=> object(c)#2 (1) { ["prop"]=> string(10) "I am awake" } [1]=> &NULL }
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/68Hg5 on line 9
Process exited with code 255.