3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class A { abstract protected function test(); } class C extends A { protected function test() { return 'C'; } } class D extends A { public function prnt(A $a) { echo $a->test(); } protected function test() { return 'D'; } } $d = new D; $c = new C; $d->prnt($d); $d->prnt($c); trait E { protected function test() { return 'E'; } } class B extends A { use E; } $b = new B; $d->prnt($b);
Output for 8.2.20 - 8.2.30, 8.3.8 - 8.3.30, 8.4.1 - 8.4.14, 8.4.16 - 8.4.18, 8.5.0 - 8.5.3
DCE
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
DC Fatal error: Uncaught Error: Call to protected method B::test() from scope D in /in/TPTS9:16 Stack trace: #0 /in/TPTS9(44): D->prnt(Object(B)) #1 {main} thrown in /in/TPTS9 on line 16
Process exited with code 255.

preferences:
69.75 ms | 987 KiB | 4 Q