3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class ParentClass { public function __get(string $name) { echo "__get($name) was called\n"; } } class ChildClass extends ParentClass { public $foo { get => parent::$foo::get(); } } (new ParentClass)->foo; (new ChildClass)->foo;
Output for 8.4.1 - 8.4.3
__get(foo) was called Fatal error: Uncaught Error: Undefined property ParentClass::$foo in /in/Y27mB:13 Stack trace: #0 /in/Y27mB(18): ChildClass->$foo::get() #1 {main} thrown in /in/Y27mB on line 13
Process exited with code 255.
Output for 8.2.0 - 8.2.27, 8.3.0 - 8.3.16
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/Y27mB on line 12
Process exited with code 255.

preferences:
172.12 ms | 1001 KiB | 7 Q