3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Singleton { private function __construct(){} private function __clone(){} private function __sleep(){} private function __wakeup(){} private static $instance; public static function getInstance() { if ( ! self::$instance) { self::$instance = new static(); } return self::$instance; } } $obj1 = Singleton::getInstance(); $obj2 = Singleton::getInstance(); var_dump(spl_object_hash($obj1) == spl_object_hash($obj2)); $cloner = function(){ return function(){return clone $this;}; } $obj3 = $cloner::bindTo($obj1)->__invoke(); var_dump(spl_object_hash($obj1) == spl_object_hash($obj3));
Output for 5.4.0 - 5.4.26
Parse error: syntax error, unexpected '$obj3' (T_VARIABLE) in /in/hlul5 on line 37
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE in /in/hlul5 on line 37
Process exited with code 255.