3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Configure here: $userSpecifiedPath = '/'; // ================================================================ // Don't edit below // ================================================================ $routerConfig = <<<CONFIG [/] "Controller" = "HomepageController" [404] "Controller" = "404Controller" CONFIG; class Router { private $routes; public function __construct($routes) { $this->routes = $routes; } public function getControllerFromPath($path) { if(array_key_exists($path, $this->routes) === true) { return $this->routes[$path]; } elseif(array_key_exists('404', $this->routes) === true) { return $this->routes['404']; } } } $routes = parse_ini_string($routerConfig, true); $Router = new Router($routes); echo 'Using controller: ' . $Router->getControllerFromPath($userSpecifiedPath);
Output for git.master, git.master_jit
Warning: syntax error, unexpected '"' in Unknown on line 2 in /in/6SKJC on line 41 Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, bool given in /in/6SKJC:33 Stack trace: #0 /in/6SKJC(43): Router->getControllerFromPath('/') #1 {main} thrown in /in/6SKJC on line 33
Process exited with code 255.
Output for rfc.property-hooks
Warning: syntax error, unexpected '"' in Unknown on line 2 in /in/6SKJC on line 41 Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, false given in /in/6SKJC:33 Stack trace: #0 /in/6SKJC(43): Router->getControllerFromPath('/') #1 {main} thrown in /in/6SKJC on line 33
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:
36.35 ms | 401 KiB | 8 Q