3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo extends PDO { private function __construct() {} public static function getInstance() { return new self(); } public function bar() { return 'baz'; } } $foo = Foo::getInstance(); echo $foo->bar();
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.33, 7.4.3 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
baz
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.28
Fatal error: Access level to Foo::__construct() must be public (as in class PDO) in /in/q5CYc on line 10
Process exited with code 255.

preferences:
139.39 ms | 402 KiB | 198 Q