3v4l.org

run code in 500+ PHP versions simultaneously
<?php abstract class P { protected $foo; } 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.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.11
int(2) Fatal error: Uncaught Error: Cannot access protected property C1::$foo in /in/OJWLS:14 Stack trace: #0 /in/OJWLS(18): C2::foo(Object(C1)) #1 {main} thrown in /in/OJWLS on line 14
Process exited with code 255.
Output for 8.4.12 - 8.4.26, 8.5.0 - 8.5.11
int(2) int(1)

preferences:
30.33 ms | 1155 KiB | 9 Q