3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object = (object) array( "foo" => 42, "" => 37, "bar" => 19, ); echo "+ object created:\n"; var_dump($o); echo "\nenum properties:\n"; foreach ($o as $p => $v) { var_dump($p); } echo "\nget_object_vars()\n"; var_dump(get_object_vars($o));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
+ object created: Warning: Undefined variable $o in /in/N742H on line 8 NULL enum properties: Warning: Undefined variable $o in /in/N742H on line 10 Warning: foreach() argument must be of type array|object, null given in /in/N742H on line 10 get_object_vars() Warning: Undefined variable $o in /in/N742H on line 14 Fatal error: Uncaught TypeError: get_object_vars(): Argument #1 ($object) must be of type object, null given in /in/N742H:14 Stack trace: #0 /in/N742H(14): get_object_vars(NULL) #1 {main} thrown in /in/N742H on line 14
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
+ object created: Notice: Undefined variable: o in /in/N742H on line 8 NULL enum properties: Notice: Undefined variable: o in /in/N742H on line 10 Warning: Invalid argument supplied for foreach() in /in/N742H on line 10 get_object_vars() Notice: Undefined variable: o in /in/N742H on line 14 Warning: get_object_vars() expects parameter 1 to be object, null given in /in/N742H on line 14 NULL
Output for 7.3.32 - 7.3.33, 7.4.26
+ object created: NULL enum properties: Warning: Invalid argument supplied for foreach() in /in/N742H on line 10 get_object_vars() Warning: get_object_vars() expects parameter 1 to be object, null given in /in/N742H on line 14 NULL
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
+ object created: Notice: Undefined variable: o in /in/N742H on line 8 NULL enum properties: Notice: Undefined variable: o in /in/N742H on line 10 Warning: Invalid argument supplied for foreach() in /in/N742H on line 10 get_object_vars() Notice: Undefined variable: o in /in/N742H on line 14 bool(false)
Output for 5.0.4 - 5.0.5
+ object created: Notice: Undefined variable: o in /in/N742H on line 8 NULL enum properties: Warning: Invalid argument supplied for foreach() in /in/N742H on line 10 get_object_vars() bool(false)
Output for 4.3.0 - 4.3.10, 4.4.0 - 4.4.9, 5.0.0 - 5.0.3
+ object created: Notice: Undefined variable: o in /in/N742H on line 8 NULL enum properties: Warning: Invalid argument supplied for foreach() in /in/N742H on line 10 get_object_vars() bool(false)
Output for 4.3.11
+ object created: Notice: Undefined variable: o in /in/N742H on line 8 NULL enum properties: get_object_vars() bool(false)

preferences:
203.97 ms | 401 KiB | 317 Q