3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class hell { private $ruler = 'devil'; function cry(){ echo $this->ruler; } } $inst = new hell(); $inst->cry(); $in2 = Closure::bind(function () {$this->ruler = 'jesus';}, $inst, get_class($inst)); $in2(); $inst->cry(); class Singleton { protected static $instance; // object instance private function __construct(){ /* ... @return Singleton */ } // Защищаем от создания через new Singleton private function __clone() { /* ... @return Singleton */ } // Защищаем от создания через клонирование private function __wakeup() { /* ... @return Singleton */ } // Защищаем от создания через unserialize public static function getInstance() { // Возвращает единственный экземпляр класса. @return Singleton if ( !isset(self::$instance) ) { $class = __CLASS__; self::$instance = new $class(); selt::$instance->id = mt_rand(1,1000); } return self::$instance; } public function doAction() { echo $this->id; } } Singleton::getInstance()->doAction(); // Применение $singy = Singleton::getInstance();
Output for 7.0.0 - 7.1.0
deviljesus Fatal error: Uncaught Error: Class 'selt' not found in /in/eXOKI:28 Stack trace: #0 /in/eXOKI(34): Singleton::getInstance() #1 {main} thrown in /in/eXOKI on line 28
Process exited with code 255.
Output for hhvm-3.12.0
deviljesus Fatal error: Uncaught Error: Class undefined: selt in /in/eXOKI:28 Stack trace: #0 /in/eXOKI(34): Singleton::getInstance() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0
deviljesus Fatal error: Class undefined: selt in /in/eXOKI on line 28
Process exited with code 255.
Output for 5.4.0 - 5.6.28
deviljesus Fatal error: Class 'selt' not found in /in/eXOKI on line 28
Process exited with code 255.
Output for 5.3.0 - 5.3.29
devil Fatal error: Call to undefined method Closure::bind() in /in/eXOKI on line 15
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/eXOKI on line 15
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/eXOKI on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/eXOKI on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/eXOKI on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/eXOKI on line 4
Process exited with code 255.