3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $object = (object) array( "foo" => 42, "" => 37, "bar" => 19, ); echo "+ object created:\n"; var_dump($object); echo "\nenum properties:\n"; foreach ($object as $p => $v) { var_dump($p); } echo "\nget_object_vars()\n"; var_dump(get_object_vars($object));
Output for 7.1.0
+ object created: object(stdClass)#1 (3) { ["foo"]=> int(42) [""]=> int(37) ["bar"]=> int(19) } enum properties: string(3) "foo" string(0) "" string(3) "bar" get_object_vars() array(3) { ["foo"]=> int(42) [""]=> int(37) ["bar"]=> int(19) }
Output for 7.0.6 - 7.0.14
+ object created: object(stdClass)#1 (3) { ["foo"]=> int(42) [""]=> int(37) ["bar"]=> int(19) } enum properties: string(3) "foo" string(3) "bar" get_object_vars() array(3) { ["foo"]=> int(42) [""]=> int(37) ["bar"]=> int(19) }
Output for 7.0.0 - 7.0.5
+ object created: object(stdClass)#1 (3) { ["foo"]=> int(42) Notice: Illegal member variable name in /in/a6Zum on line 8 [""]=> int(37) ["bar"]=> int(19) } enum properties: Notice: Illegal member variable name in /in/a6Zum on line 10 string(3) "foo" string(3) "bar" get_object_vars() array(3) { ["foo"]=> int(42) [""]=> int(37) ["bar"]=> int(19) }
Output for 5.1.0 - 5.1.6, 5.6.21 - 5.6.28
+ object created: object(stdClass)#1 (3) { ["foo"]=> int(42) [""]=> int(37) ["bar"]=> int(19) } enum properties: string(3) "foo" string(3) "bar" get_object_vars() array(2) { ["foo"]=> int(42) ["bar"]=> int(19) }
Output for 5.2.4 - 5.6.20
+ object created: object(stdClass)#1 (3) { ["foo"]=> int(42) Notice: Illegal member variable name in /in/a6Zum on line 8 [""]=> int(37) ["bar"]=> int(19) } enum properties: string(3) "foo" Notice: Illegal member variable name in /in/a6Zum on line 10 string(3) "bar" get_object_vars() Notice: Illegal member variable name in /in/a6Zum on line 14 array(2) { ["foo"]=> int(42) ["bar"]=> int(19) }
Output for 5.2.0 - 5.2.3
+ object created: object(stdClass)#1 (3) { ["foo"]=> int(42) Notice: Illegal member variable name in /in/a6Zum on line 8 [""]=> int(37) ["bar"]=> int(19) } enum properties: string(3) "foo" Notice: Illegal member variable name in /in/a6Zum on line 10 string(3) "bar" get_object_vars() array(2) { ["foo"]=> int(42) ["bar"]=> int(19) }
Output for 5.0.0 - 5.0.5
+ object created: object(stdClass)#1 (3) { ["foo"]=> int(42) [":private"]=> int(37) ["bar"]=> int(19) } enum properties: string(3) "foo" string(3) "bar" get_object_vars() array(2) { ["foo"]=> int(42) ["bar"]=> int(19) }
Output for 4.3.0 - 4.4.9
+ object created: object(stdClass)(3) { ["foo"]=> int(42) [""]=> int(37) ["bar"]=> int(19) } enum properties: string(3) "foo" string(0) "" string(3) "bar" get_object_vars() array(3) { ["foo"]=> int(42) [""]=> int(37) ["bar"]=> int(19) }