3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Deferred { // } class Test { protected(set) array $loaded = []; public Deferred $instance { get => $this->instance ??= new Deferred(); set { $this->instance = $value; $this->loaded[$value::class] = $value; } } } $test = new Test(); $instance = $test->instance; var_dump($test->loaded);
Output for 8.4.1
array(0) { }
Output for 4.3.0
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/PSHJN on line 8
Process exited with code 255.

preferences:
169.21 ms | 1000 KiB | 7 Q