3v4l.org

run code in 300+ PHP versions simultaneously
<?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 Closure(); }; $obj3 = null; $obj3 = $cloner::bindTo($obj1)->__invoke(); var_dump(spl_object_hash($obj1) == spl_object_hash($obj3));
Output for git.master, git.master_jit, rfc.property-hooks
Warning: The magic method Singleton::__sleep() must have public visibility in /in/4I9W2 on line 7 Warning: The magic method Singleton::__wakeup() must have public visibility in /in/4I9W2 on line 8 bool(true) Fatal error: Uncaught Error: Non-static method Closure::bindTo() cannot be called statically in /in/4I9W2:38 Stack trace: #0 {main} thrown in /in/4I9W2 on line 38
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.55 ms | 401 KiB | 8 Q