3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Foo { private function doFoo() { echo __METHOD__; } } class Bar extends Foo { public static function doBar() { $bar = new Bar(); $bar->doFoo(); } } class Baz { public static function baz() { echo __METHOD__; } } Baz::baz();
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.6
Baz::baz
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; Baz has a deprecated constructor in /in/8p8bQ on line 16 Fatal error: Constructor Baz::baz() cannot be static in /in/8p8bQ on line 16
Process exited with code 255.
Output for 5.5.24 - 5.5.31, 5.6.8 - 5.6.17
Fatal error: Constructor Baz::baz() cannot be static in /in/8p8bQ on line 20
Process exited with code 255.

preferences:
71.25 ms | 402 KiB | 48 Q