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) { $this->instance = new self; } return static::instance; } } $a = A::getInstance(); var_dump($a);
based on 4pU6I
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/qcdNo:9 Stack trace: #0 /in/qcdNo(17): A::getInstance() #1 {main} thrown in /in/qcdNo 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/qcdNo on line 9
Process exited with code 255.