3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Aurora { public static $items = array(); public function __construct(){ $this->report(); $this->init(); } protected function init(){ ToroHook::add("404", function() { }); Toro::serve(array( "/:alpha" => array( "directory" => "page", "controller" => "Page", "action" => "view", "params" => array("page") ), "/:number" => array( "directory" => "page", "controller" => "Page", "action" => "number", "params" => array("page") ) )); } public static function run($handler = array(),$request_method = "any",$regex_matches){ if(!empty($handler)){ vardump($handler); } } } class Toro{ public static function serve($routes = array()) { $tokens = array( ":string" => "([a-zA-Z]+)", ":number" => "([0-9]+)", ":alpha" => "([a-zA-Z0-9-_]+)", ":any" => "(.*)" ); ToroHook::fire("before_request", compact("routes")); $request_method = strtolower($_SERVER["REQUEST_METHOD"]); $b = false; $uri = @explode("/", $_SERVER["REQUEST_URI"])[2]; $path_info = ((!empty($uri)) ? $path_info = "/".$uri : $path_info = "/"); $discovered_handler = null; $path_info = "/a" if (isset($routes[$path_info])) { $discovered_handler = $routes[$path_info]; $b = true; }else if ($routes) { foreach ($routes as $pattern => $handler) { if(preg_match("#^/?" . strtr($pattern , $tokens) . "/?$#", $path_info, $regex_matches)){ unset($regex_matches[0]); $match = $regex_matches; $discovered_handler = $handler; $b = true; } } } $handler_instance = null; if ($b) { if (self::is_xhr_request()) { header("Content-type: application/json"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); $request_method .= "_xhr"; } if ($b) { ToroHook::fire("before_handler", compact("routes", "discovered_handler", "request_method", "regex_matches")); Aurora::run($discovered_handler,$request_method,$match); ToroHook::fire("after_handler", compact("routes", "discovered_handler", "request_method", "regex_matches", "result")); } else { ToroHook::fire("404", compact("routes", "discovered_handler", "request_method", "regex_matches")); } } else { ToroHook::fire("404", compact("routes", "discovered_handler", "request_method", "regex_matches")); } ToroHook::fire("after_request", compact("routes", "discovered_handler", "request_method", "regex_matches", "result")); } private static function is_xhr_request(){ return isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest"; } } class ToroHook { private static $instance; private $hooks = array(); private function __construct() {} private function __clone() {} public static function add($hook_name, $fn){ $instance = self::get_instance(); $instance->hooks[$hook_name][] = $fn; } public static function fire($hook_name, $params = null){ $instance = self::get_instance(); if (isset($instance->hooks[$hook_name])) { foreach ($instance->hooks[$hook_name] as $fn) { call_user_func_array($fn, array(&$params)); } } } public static function get_instance(){ if (empty(self::$instance)) { self::$instance = new ToroHook(); } return self::$instance; } }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.320.0040.03812.54
5.4.310.0060.03812.53
5.4.300.0060.03612.54
5.4.290.0050.03812.52
5.4.280.0060.03512.42
5.4.270.0070.03512.42
5.4.260.0030.04012.42
5.4.250.0090.03412.42
5.4.240.0030.03912.42
5.4.230.0040.03912.41
5.4.220.0050.03612.41
5.4.210.0080.03912.41
5.4.200.0050.04012.41
5.4.190.0080.03712.41
5.4.180.0050.03812.41
5.4.170.0080.03412.41
5.4.160.0060.03612.41
5.4.150.0040.03712.41
5.4.140.0060.03612.10
5.4.130.0120.04012.08
5.4.120.0080.03312.04
5.4.110.0060.03412.04
5.4.100.0070.03312.04
5.4.90.0070.03512.04
5.4.80.0090.04112.04
5.4.70.0040.05012.04
5.4.60.0110.04812.04
5.4.50.0060.03812.04
5.4.40.0060.03512.03
5.4.30.0050.03612.02
5.4.20.0080.03912.02
5.4.10.0070.03312.02
5.4.00.0050.03611.51
5.3.290.0040.04212.80
5.3.280.0050.03812.70
5.3.270.0060.03912.73
5.3.260.0090.03612.72
5.3.250.0070.03712.72
5.3.240.0030.04012.72
5.3.230.0050.03912.71
5.3.220.0070.03712.68
5.3.210.0080.03712.68
5.3.200.0070.04112.68
5.3.190.0040.04012.68
5.3.180.0060.03712.68
5.3.170.0070.03512.67
5.3.160.0070.03712.67
5.3.150.0050.03912.67
5.3.140.0080.03412.66
5.3.130.0050.05012.66
5.3.120.0070.05012.66
5.3.110.0040.04212.66
5.3.100.0020.04112.14
5.3.90.0050.03712.12
5.3.80.0070.04312.11
5.3.70.0060.04012.11
5.3.60.0060.03612.10
5.3.50.0030.04412.04
5.3.40.0050.03812.04
5.3.30.0070.03312.00
5.3.20.0060.03611.79
5.3.10.0050.03711.75
5.3.00.0080.03611.73
5.2.170.0040.0309.23
5.2.160.0060.0289.23
5.2.150.0060.0319.23
5.2.140.0090.0269.23
5.2.130.0090.0259.19
5.2.120.0030.0299.18
5.2.110.0050.0299.20
5.2.100.0040.0299.19
5.2.90.0060.0279.19
5.2.80.0070.0339.18
5.2.70.0050.0299.18
5.2.60.0030.0319.14
5.2.50.0030.0319.11
5.2.40.0050.0289.08
5.2.30.0060.0289.05
5.2.20.0010.0329.05
5.2.10.0050.0288.96
5.2.00.0030.0308.82
5.1.60.0050.0238.10
5.1.50.0060.0258.10
5.1.40.0050.0238.08
5.1.30.0010.0288.42
5.1.20.0030.0278.45
5.1.10.0010.0288.17
5.1.00.0030.0268.17
5.0.50.0070.0226.66
5.0.40.0020.0216.51
5.0.30.0050.0296.32
5.0.20.0060.0166.29
5.0.10.0020.0216.26
5.0.00.0020.0316.26
4.4.90.0010.0174.78
4.4.80.0040.0144.75
4.4.70.0020.0164.76
4.4.60.0040.0144.75
4.4.50.0020.0164.77
4.4.40.0020.0264.71
4.4.30.0010.0174.76
4.4.20.0020.0174.85
4.4.10.0010.0174.85
4.4.00.0030.0244.76
4.3.110.0040.0144.67
4.3.100.0040.0144.66
4.3.90.0040.0134.63
4.3.80.0000.0304.58
4.3.70.0030.0144.63
4.3.60.0030.0214.63
4.3.50.0030.0224.63
4.3.40.0020.0344.53
4.3.30.0020.0183.30
4.3.20.0000.0223.28
4.3.10.0000.0183.23
4.3.00.0030.01715.97

preferences:
153.02 ms | 1394 KiB | 7 Q