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); print_r($routes); $Router = new Router($routes); echo 'Using controller: ' . $Router->getControllerFromPath($userSpecifiedPath);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [/] => Array ( [Controller] => HomepageController ) [404] => Array ( [Controller] => 404Controller ) ) Warning: Array to string conversion in /in/dDs0i on line 44 Using controller: Array

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:
38.49 ms | 402 KiB | 8 Q