3v4l.org

run code in 300+ PHP versions simultaneously
<?php function GetValue(&$obj, $defaultValue = null) { return isset($obj) ? $obj : $defaultValue; } class foo { public $bar; } $x = new foo(); var_dump(GetValue($x->bar->baz)); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Fatal error: Uncaught Error: Attempt to modify property "baz" on null in /in/oesQP:9 Stack trace: #0 {main} thrown in /in/oesQP on line 9
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Creating default object from empty value in /in/oesQP on line 9 NULL
Output for 5.5.38, 5.6.0 - 5.6.25, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
NULL

preferences:
140.52 ms | 409 KiB | 5 Q