3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = new stdClass(); $a->{0} = 'X'; $a->{1} = 'Y'; var_dump($a); $x = unserialize(serialize($a)); $prop = 1; var_dump($x->$prop, $x->${"$prop"});
based on R8NTW
Output for 7.1.0
object(stdClass)#1 (2) { ["0"]=> string(1) "X" ["1"]=> string(1) "Y" } Notice: Undefined variable: 1 in /in/ifSlt on line 8 Notice: Undefined property: stdClass::$ in /in/ifSlt on line 8 string(1) "Y" NULL
Output for 7.0.0 - 7.0.14
object(stdClass)#1 (2) { ["0"]=> string(1) "X" ["1"]=> string(1) "Y" } Notice: Undefined variable: 1 in /in/ifSlt on line 8 Fatal error: Uncaught Error: Cannot access empty property in /in/ifSlt:8 Stack trace: #0 {main} thrown in /in/ifSlt on line 8
Process exited with code 255.
Output for 5.0.5 - 5.2.5, 5.3.9 - 5.6.28
object(stdClass)#1 (2) { ["0"]=> string(1) "X" ["1"]=> string(1) "Y" } Notice: Undefined variable: 1 in /in/ifSlt on line 8 Fatal error: Cannot access empty property in /in/ifSlt on line 8
Process exited with code 255.
Output for 5.2.6 - 5.3.8
object(stdClass)#1 (2) { ["0"]=> string(1) "X" ["1"]=> string(1) "Y" } Notice: Undefined property: stdClass::$1 in /in/ifSlt on line 8 Notice: Undefined variable: 1 in /in/ifSlt on line 8 Fatal error: Cannot access empty property in /in/ifSlt on line 8
Process exited with code 255.
Output for 5.0.4
object(stdClass)#1 (2) { ["0"]=> string(1) "X" ["1"]=> string(1) "Y" } Notice: Undefined variable: 1 in /in/ifSlt on line 8 Notice: Undefined property: stdClass::$ in /in/ifSlt on line 8 string(1) "Y" NULL
Output for 5.0.0 - 5.0.3
object(stdClass)#1 (2) { ["0"]=> string(1) "X" ["1"]=> string(1) "Y" } Notice: Undefined variable: 1 in /in/ifSlt on line 8 Notice: Undefined property: stdClass::$ in /in/ifSlt on line 8 string(1) "Y" NULL
Output for 4.3.3 - 4.4.9
Fatal error: Property name must be a string in /in/ifSlt on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.2

Process exited with code 139.