3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Singleton { private static $instance = null; final private function __construct() {} final private function __clone() {} public static function getInstance() { if (!self::$instance) { self::$instance = new self; } return self::$instance; } } $oneInstance = Singleton::getInstance(); $creator = function () { return new self(); } $secondInstance = $creator->bindTo(null, 'Singleton')->__invoke(); var_dump($oneInstance, $secondInstance);
Output for 5.4.0 - 5.4.25
Parse error: syntax error, unexpected '$secondInstance' (T_VARIABLE) in /in/2pKcV on line 23
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE in /in/2pKcV on line 23
Process exited with code 255.