3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DIContainer { private $properties = array(); public function __set($propertyName, $value) { $this->properties[$propertyName] = $value; } public function __get($propertyName) { return is_callable($this->properties[$propertyName]) ? $this->properties[$propertyName]() : $this->properties[$propertyName]; } } class SessionClass { public $cookieName; public function __construct($cookieName) { $this->cookieName = $cookieName; } } class Application { public static function run() { $di = new DIContainer(); $di->sessionCookieName = 'id'; $di->sessionStorageClass = 'Session'; $di->sessionStorage = function ($di) { $className = $di->sessionStorageClass; return new $className($di->sessionCookieName); }; $sessionHandler = $di->sessionStorage; echo get_class($sessionHandler), "\n", $sessionHandler->cookieName; } } Application::run();
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Application::{closure}(), 0 passed in /in/taWan on line 9 and exactly 1 expected in /in/taWan:25 Stack trace: #0 /in/taWan(9): Application::{closure}() #1 /in/taWan(29): DIContainer->__get('sessionStorage') #2 /in/taWan(34): Application::run() #3 {main} thrown in /in/taWan on line 25
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:
47.73 ms | 401 KiB | 8 Q