3v4l.org

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