3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private static $instance; public static function getInstance() { if (null === static::$instance = new self) { static::$instance = new self; } return static::instance; } } $a = A::getInstance(); var_dump($a);
based on o3MlE
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Undefined class constant 'instance' in /in/bf9Pg:13 Stack trace: #0 /in/bf9Pg(17): A::getInstance() #1 {main} thrown in /in/bf9Pg on line 13
Process exited with code 255.
Output for 5.3.21 - 5.6.28
Fatal error: Undefined class constant 'instance' in /in/bf9Pg on line 13
Process exited with code 255.