3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected static $_instance; protected function __construct() {} public static function getInstance() { if (self::$_instance === null) { self::$_instance = new static(); } return self::$_instance; } } class B extends A { public function hi() { echo 'HI'; } } echo get_class(B::getInstance()); B::hi();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
B Fatal error: Uncaught Error: Non-static method B::hi() cannot be called statically in /in/5UQE7:26 Stack trace: #0 {main} thrown in /in/5UQE7 on line 26
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
B Deprecated: Non-static method B::hi() should not be called statically in /in/5UQE7 on line 26 HI
Output for 7.3.32 - 7.3.33
BHI
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
B Strict Standards: Non-static method B::hi() should not be called statically in /in/5UQE7 on line 26 HI

preferences:
180.06 ms | 402 KiB | 227 Q