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.3.0 - 5.4.26
Parse error: syntax error, unexpected '}' in /in/hqcR1 on line 31
Process exited with code 255.