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 new function{}( return clone $this; ); }; $obj3 = null; $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 'function' (T_FUNCTION) in /in/jVovk on line 31
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_FUNCTION in /in/jVovk on line 31
Process exited with code 255.