3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $class = new stdClass(); $class->field = 'foo'; var_dump($class); $array = array(1 => $class); var_dump($array); $json_sting = json_encode($array); var_dump($json_sting); $array_obj = json_decode($json_sting); var_dump($array_obj); $array = (array) $array_obj; var_dump($array); var_dump($array[1]);
Output for 7.0.0 - 7.1.0
object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } array(1) { [1]=> object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } } string(21) "{"1":{"field":"foo"}}" object(stdClass)#3 (1) { ["1"]=> object(stdClass)#2 (1) { ["field"]=> string(3) "foo" } } array(1) { ["1"]=> object(stdClass)#2 (1) { ["field"]=> string(3) "foo" } } Notice: Undefined offset: 1 in /in/RoV0N on line 15 NULL
Output for hhvm-3.10.0 - 3.12.0
object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } array(1) { [1]=> object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } } string(21) "{"1":{"field":"foo"}}" object(stdClass)#2 (1) { ["1"]=> object(stdClass)#3 (1) { ["field"]=> string(3) "foo" } } array(1) { ["1"]=> object(stdClass)#3 (1) { ["field"]=> string(3) "foo" } } Notice: Undefined index: 1 in /in/RoV0N on line 15 NULL
Output for 5.3.0 - 5.6.28
object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } array(1) { [1]=> object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } } string(21) "{"1":{"field":"foo"}}" object(stdClass)#2 (1) { ["1"]=> object(stdClass)#3 (1) { ["field"]=> string(3) "foo" } } array(1) { ["1"]=> object(stdClass)#3 (1) { ["field"]=> string(3) "foo" } } Notice: Undefined offset: 1 in /in/RoV0N on line 15 NULL
Output for 5.2.0 - 5.2.17
object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } array(1) { [1]=> object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } } string(21) "{"1":{"field":"foo"}}" object(stdClass)#2 (1) { ["1"]=> object(stdClass)#3 (1) { ["field"]=> string(3) "foo" } } array(1) { ["1"]=> object(stdClass)#3 (1) { ["field"]=> string(3) "foo" } } Notice: Undefined offset: 1 in /in/RoV0N on line 15 NULL
Output for 5.0.0 - 5.1.6
object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } array(1) { [1]=> object(stdClass)#1 (1) { ["field"]=> string(3) "foo" } } Fatal error: Call to undefined function json_encode() in /in/RoV0N on line 9
Process exited with code 255.
Output for 4.4.5 - 4.4.9
object(stdClass)(1) { ["field"]=> string(3) "foo" } array(1) { [1]=> object(stdClass)(1) { ["field"]=> string(3) "foo" } } Fatal error: Call to undefined function: json_encode() in /in/RoV0N on line 9
Process exited with code 255.
Output for 4.3.2 - 4.4.4
object(stdClass)(1) { ["field"]=> string(3) "foo" } array(1) { [1]=> object(stdClass)(1) { ["field"]=> string(3) "foo" } } Fatal error: Call to undefined function: json_encode() in /in/RoV0N on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
object(stdClass)(1) { ["field"]=> string(3) "foo" } array(1) { [1]=> object(stdClass)(1) { ["field"]=> string(3) "foo" } } Fatal error: Call to undefined function: json_encode() in /in/RoV0N on line 9