3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Loader { private static $instances; public static function get_instance($class) { if(!isset(self::$instances[$class])) { self::$instances[$class] = new $class(); } return self::$instances[$class]; } public static function debug() { print_r(self::$instances); } } class One{ public function __toString() { return 'One'; } } class Two{ public function __toString() { return 'Two'; } } class Foo{ public function __toString() { return 'Foo'; } } $foo = Loader::get_instance('Foo'); $one = Loader::get_instance('One'); $two = Loader::get_instance('Two'); $foo2 = Loader::get_instance('Foo'); $foo3 = Loader::get_instance('Foo'); Loader::debug();
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [Foo] => Foo Object ( ) [One] => One Object ( ) [Two] => Two Object ( ) )

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