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 function(){ return clone $this; }; }; $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/IT0t9 on line 7 Warning: The magic method Singleton::__wakeup() must have public visibility in /in/IT0t9 on line 8 bool(true) bool(false)

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:
47.31 ms | 401 KiB | 8 Q