3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class P { abstract protected $foo { get; } } class C1 extends P { protected $foo = 1; } class C2 extends P { protected $foo = 2; static function foo($c) { return $c->foo; } } var_dump(C2::foo(new C2)); var_dump(C2::foo(new C1));
Output for 8.4.12
int(2) int(1)
Output for 8.4.9 - 8.4.11
int(2) Fatal error: Uncaught Error: Cannot access protected property C1::$foo in /in/7Xf05:14 Stack trace: #0 /in/7Xf05(18): C2::foo(Object(C1)) #1 {main} thrown in /in/7Xf05 on line 14
Process exited with code 255.
Output for 8.1.33
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/7Xf05 on line 4
Process exited with code 255.
Output for 7.3.33
Parse error: syntax error, unexpected '{', expecting ',' or ';' in /in/7Xf05 on line 4
Process exited with code 255.

preferences:
168.05 ms | 1006 KiB | 7 Q