3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace App\Com; class Test { protected static $_instance; public static function getInstance() { if(!self::$_instance) { self::$_instance = new self(); } return self::$_instance; } public function test() { return 'works'; } protected function __construct() { } } class Service { protected static $_instance; protected $_connection; protected $_case = []; public static function getInstance() { if(!self::$_instance) { self::$_instance = new self(); } return self::$_instance; } protected function __construct() { $this->_case[] = Test::getInstance(); // TODO: Establish entity to database } public function using($nsp) { foreach($this->_case as $obj) { if($nsp instanceof $obj) { return $obj::getInstance(); } } throw new \Exception("Call to $nsp did not match any libraries."); } protected function __clone() {} } echo Service::getInstance()->using('\App\Com\Test')->test();
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Exception: Call to \App\Com\Test did not match any libraries. in /in/knhjm:58 Stack trace: #0 /in/knhjm(64): App\Com\Service->using('\\App\\Com\\Test') #1 {main} thrown in /in/knhjm on line 58
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:
106.9 ms | 405 KiB | 5 Q