3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = new stdClass; $a->b->c->d = 42; var_dump($a);
based on 3CbdT
Output for 8.0.0
Fatal error: Uncaught Error: Attempt to modify property "c" on null in /in/dS0Jv:3 Stack trace: #0 {main} thrown in /in/dS0Jv on line 3
Process exited with code 255.
Output for 7.4.0 - 7.4.12
Warning: Creating default object from empty value in /in/dS0Jv on line 3 Warning: Creating default object from empty value in /in/dS0Jv on line 3 object(stdClass)#1 (1) { ["b"]=> object(stdClass)#2 (1) { ["c"]=> object(stdClass)#3 (1) { ["d"]=> int(42) } } }
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.24
Warning: Creating default object from empty value in /in/dS0Jv on line 3 object(stdClass)#1 (1) { ["b"]=> object(stdClass)#2 (1) { ["c"]=> object(stdClass)#3 (1) { ["d"]=> int(42) } } }