3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public static $instance; public static function getInstance() { if (static::$instance === null) { static::$instance = new static(); } } } class B extends A { public static $instance; } echo get_class(A::getInstance()) . PHP_EOL; echo get_class(B::getInstance()) . PHP_EOL; echo get_class(A::getInstance()) . PHP_EOL;
based on ZKsH7
Output for 7.2.0
Warning: get_class() expects parameter 1 to be object, null given in /in/VIeOm on line 19 Warning: get_class() expects parameter 1 to be object, null given in /in/VIeOm on line 20 Warning: get_class() expects parameter 1 to be object, null given in /in/VIeOm on line 21
Output for 5.3.18 - 7.1.10
Warning: get_class() called without object from outside a class in /in/VIeOm on line 19 Warning: get_class() called without object from outside a class in /in/VIeOm on line 20 Warning: get_class() called without object from outside a class in /in/VIeOm on line 21