3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Foo { private function foo() { echo __CLASS__; } } class Bar extends Foo { public static function bar() { $bar = new Bar(); $bar->foo(); } } Bar::bar();
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Call to private method Foo::foo() from scope Bar in /in/UPiiF:12 Stack trace: #0 /in/UPiiF(16): Bar::bar() #1 {main} thrown in /in/UPiiF on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.2
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Foo has a deprecated constructor in /in/UPiiF on line 3 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Bar has a deprecated constructor in /in/UPiiF on line 9 Fatal error: Constructor Bar::bar() cannot be static in /in/UPiiF on line 9
Process exited with code 255.
Output for 5.5.24 - 5.5.31, 5.6.8 - 5.6.17
Fatal error: Constructor Bar::bar() cannot be static in /in/UPiiF on line 14
Process exited with code 255.

preferences:
68.19 ms | 402 KiB | 48 Q