3v4l.org

run code in 500+ 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.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
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:
89.98 ms | 1705 KiB | 4 Q