3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Router { protected $routes = []; protected $params = [] ; protected $namespace = 'App\Controllers\\'; public function add($route , $params ) { $route = preg_replace('/^\//','' , $route); $route = preg_replace('/\//' , '\\/' , $route); $route = preg_replace('/\{([a-z]+)\}/' , '?([a-z0-9ا-ی]+)' , $route); $route = '/^' . $route . '\/?$/i'; if(is_string($params)) { list($AllParams['controller'] , $AllParams['method']) = explode('@' , $params); } if(is_array($params)) { list($AllParams['controller'] , $AllParams['method']) = explode('@' , $params['uses']); unset($params['uses']); $AllParams = array_merge($AllParams , $params); } $this->routes[$route] = $AllParams; } public function match($url) { foreach ($this->routes as $route => $params) { if(preg_match($route , $url , $matches)) { foreach ($matches as $key => $match) { if(is_string($key)) { $params['params'][$key] = $match; } } $this->params = $params; return true; } } return false; } public function dispatch($url) { $url = $this->removeVariblesOfQueryString($url); if($this->match($url)) { $controller = $this->params['controller']; $controller = $this->getNameSpace() . $controller; if(class_exists($controller)) { $controller_object = new $controller(); $method = $this->params['method']; if(is_callable([$controller_object , $method])) { $this->params['params'] = isset($this->params['params']) ? $this->params['params'] : []; echo call_user_func_array([$controller_object , $method] , $this->params['params']); } else { throw new \Exception("Method {$method} (in controller {$controller}) not found"); } } else { throw new \Exception("Controller class {$controller} not found",404); } } else { throw new \Exception("no route matched.",404); } } public function getRoutes() { return $this->routes; } public function getParams() { return $this->params; } protected function getNameSpace() { $namespace = $this->namespace; if(array_key_exists('namespace' , $this->params)) { $namespace .= $this->params['namespace'] . '\\'; } return $namespace; } protected function removeVariblesOfQueryString($url) { if($url != '') { $parts = explode("&" , $url , 2); if(strpos($parts[0] , '=') === false) { $url = $parts[0]; } else { $url = ''; } return $url; } } } $router = new Router(); $router->add('/news/{city}','cityController@index'); $router->dispatch('news/اراک');

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)
8.3.60.0000.01518.81
8.3.50.0060.00918.27
8.3.40.0090.00919.21
8.3.30.0060.00919.04
8.3.20.0040.00422.61
8.3.10.0040.00421.95
8.3.00.0080.00022.46
8.2.180.0160.00025.92
8.2.170.0130.00322.96
8.2.160.0070.00720.41
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0040.00421.17
8.2.110.0070.00321.16
8.2.100.0040.00818.16
8.2.90.0040.00418.22
8.2.80.0030.00617.97
8.2.70.0060.00318.04
8.2.60.0040.00418.28
8.2.50.0050.00318.10
8.2.40.0050.00319.48
8.2.30.0040.00419.36
8.2.20.0040.00418.38
8.2.10.0000.00819.48
8.2.00.0000.00719.33
8.1.280.0090.00625.92
8.1.270.0030.00620.57
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0030.00722.21
8.1.230.0070.00422.74
8.1.220.0040.00417.78
8.1.210.0040.00418.77
8.1.200.0090.00017.73
8.1.190.0000.00817.60
8.1.180.0040.00818.10
8.1.170.0040.00420.91
8.1.160.0040.00419.07
8.1.150.0080.00018.96
8.1.140.0060.00320.93
8.1.130.0000.00720.16
8.1.120.0050.00217.68
8.1.110.0050.00217.69
8.1.100.0040.00417.66
8.1.90.0000.00717.66
8.1.80.0030.00617.63
8.1.70.0000.00717.65
8.1.60.0070.00317.78
8.1.50.0080.00017.62
8.1.40.0030.00517.73
8.1.30.0090.00017.68
8.1.20.0000.00817.90
8.1.10.0030.00617.63
8.1.00.0040.00417.67
8.0.300.0000.00719.89
8.0.290.0000.00817.00
8.0.280.0070.00018.41
8.0.270.0030.00517.22
8.0.260.0000.00620.01
8.0.250.0000.00717.18
8.0.240.0000.00717.21
8.0.230.0000.00717.09
8.0.220.0040.00417.11
8.0.210.0070.00017.10
8.0.200.0040.00417.09
8.0.190.0000.00717.13
8.0.180.0060.00317.15
8.0.170.0080.00017.13
8.0.160.0000.00817.04
8.0.150.0040.00417.09
8.0.140.0040.00417.11
8.0.130.0000.00613.53
8.0.120.0000.00817.09
8.0.110.0030.00517.09
8.0.100.0030.00516.98
8.0.90.0030.00617.11
8.0.80.0040.01117.10
8.0.70.0030.00517.10
8.0.60.0040.00417.26
8.0.50.0040.00417.02
8.0.30.0100.00817.38
8.0.20.0070.01117.59
8.0.10.0040.00417.10
8.0.00.0200.01917.42
7.4.330.0000.00515.55
7.4.320.0060.00016.77
7.4.300.0070.00016.77
7.4.290.0070.00016.68
7.4.280.0080.00316.80
7.4.270.0000.00716.79
7.4.260.0000.00613.64
7.4.250.0000.00716.80
7.4.240.0020.00616.88
7.4.230.0000.00716.68
7.4.220.0050.00216.82
7.4.210.0070.01116.87
7.4.200.0030.00316.95
7.4.140.0140.01117.86
7.4.130.0110.01717.31
7.4.120.0200.00917.33
7.4.110.0200.01117.30
7.4.100.0150.01617.39
7.4.90.0210.00717.40
7.4.80.0190.00718.63
7.4.70.0190.01017.42
7.4.60.0140.01617.25
7.4.50.0130.01317.28
7.4.40.0220.00517.26
7.4.30.0300.00917.86
7.4.20.0280.01417.86
7.4.10.0270.01317.86
7.4.00.0100.01015.84
7.3.330.0070.00016.64
7.3.320.0050.00013.59
7.3.310.0030.00316.43
7.3.300.0000.00716.58
7.3.290.0030.00516.63
7.3.280.0100.00616.55
7.3.260.0090.01517.86
7.3.250.0300.00817.86
7.3.240.0150.00716.96
7.3.230.0150.01117.27
7.3.220.0240.02017.86
7.3.210.0150.01117.31
7.3.200.0170.00917.24
7.3.190.0210.01117.25
7.3.180.0170.00917.29
7.3.170.0170.01417.24
7.3.160.0150.01217.23
7.3.150.0240.01717.86
7.3.140.0390.00417.86
7.3.130.0320.00717.86
7.3.120.0120.01215.97
7.3.110.0090.01415.93
7.3.100.0090.01015.67
7.3.90.0130.00815.59
7.3.80.0150.00615.54
7.3.70.0100.01015.63
7.3.60.0120.00915.56
7.3.50.0100.01215.62
7.3.40.0120.00915.60
7.3.30.0130.00815.67
7.3.20.0160.00816.38
7.3.10.0130.00816.40
7.3.00.0120.00816.29
7.2.340.0310.00617.86
7.2.330.0190.01017.38
7.2.320.0170.01617.47
7.2.310.0210.00717.44
7.2.300.0190.00717.29
7.2.290.0180.01117.34
7.2.280.0340.01017.86
7.2.270.0320.01317.86
7.2.260.0280.01117.86
7.2.250.0150.00916.20
7.2.240.0170.01016.25
7.2.230.0120.00915.80
7.2.220.0120.00815.74
7.2.210.0130.00915.76
7.2.200.0130.00815.80
7.2.190.0110.01015.78
7.2.180.0120.00915.87
7.2.170.0090.01215.82
7.2.160.0150.01016.06
7.2.150.0200.00816.21
7.2.140.0180.01016.16
7.2.130.0250.00616.10
7.2.120.0140.01016.24
7.2.110.0190.00916.10
7.2.100.0140.01216.03
7.2.90.0150.01216.22
7.2.80.0120.01316.14
7.2.70.0160.01116.06
7.2.60.0180.00616.10
7.2.50.0150.00816.17
7.2.40.0170.00916.21
7.2.30.0170.00616.30
7.2.20.0150.00916.18
7.2.10.0150.00816.18
7.2.00.0200.01016.11
7.1.330.0180.00716.69
7.1.320.0080.01315.55
7.1.310.0100.00915.53
7.1.300.0090.01115.69
7.1.290.0130.01015.66
7.1.280.0100.01115.56
7.1.270.0120.01015.66
7.1.260.0180.00815.57
7.1.250.0140.00815.34
7.1.240.0230.01317.86
7.1.230.0280.01017.86
7.1.220.0360.00317.86
7.1.210.0290.00617.86
7.1.200.0230.01317.86
7.1.190.0190.01117.86
7.1.180.0700.00417.86
7.1.170.0370.01117.86
7.1.160.0200.01417.86
7.1.150.0210.01317.86
7.1.140.0230.00717.86
7.1.130.0210.01717.86
7.1.120.0220.01017.86
7.1.110.0220.01817.86
7.1.100.0260.00717.86
7.1.90.0180.01317.86
7.1.80.0280.00417.86
7.1.70.0240.01217.86
7.1.60.0250.01117.86
7.1.50.0270.00917.86
7.1.40.0170.01717.86
7.1.30.0230.01017.86
7.1.20.0290.00917.86
7.1.10.0260.00317.86
7.1.00.0300.00717.86
7.0.330.0240.01117.86
7.0.320.0210.01117.86
7.0.310.0290.00617.86
7.0.300.0240.01417.86
7.0.290.0210.01417.86
7.0.280.0250.01317.86
7.0.270.0190.01217.86
7.0.260.0270.00817.86
7.0.250.0320.00317.86
7.0.240.0540.00717.86
7.0.230.0250.00617.86
7.0.220.0220.01417.86
7.0.210.0440.00917.86
7.0.200.0270.01417.86
7.0.190.0200.01517.86
7.0.180.0270.00317.86
7.0.170.0190.01017.86
7.0.160.0230.01017.86
7.0.150.0190.01217.86
7.0.140.0240.00617.86
7.0.130.0310.00617.86
7.0.120.0250.00417.86
7.0.110.0270.00817.86
7.0.100.0220.00717.86
7.0.90.0170.01417.86
7.0.80.0230.01417.86
7.0.70.0260.00917.86
7.0.60.0190.01317.86
7.0.50.0170.01417.86
7.0.40.0290.00717.86
7.0.30.0340.00817.86
7.0.20.0220.01717.86
7.0.10.0240.00717.86
7.0.00.0080.02317.86
5.6.400.0230.01317.86
5.6.390.0330.00417.86
5.6.380.0280.00717.86
5.6.370.0260.01117.86
5.6.360.0250.01017.86
5.6.350.0200.01717.86
5.6.340.0270.00617.86
5.6.330.0240.01117.86
5.6.320.0210.01317.86
5.6.310.0220.01117.86
5.6.300.0210.01117.86
5.6.290.0260.00617.86
5.6.280.0170.02117.86
5.6.270.0210.01417.86
5.6.260.0190.01417.86
5.6.250.0510.00017.86
5.6.240.0260.01117.86
5.6.230.0250.01217.86
5.6.220.0260.01217.86
5.6.210.0240.01117.86
5.6.200.0210.00917.86
5.6.190.0180.01817.86
5.6.180.0230.01517.86
5.6.170.0200.01717.86
5.6.160.0230.01217.86
5.6.150.0220.01217.86
5.6.140.0230.01017.86
5.6.130.0210.01217.86
5.6.120.0290.00617.86
5.6.110.0220.01117.86
5.6.100.0330.00417.86
5.6.90.0280.01017.86
5.6.80.0220.01117.86
5.6.70.0170.01317.86
5.6.60.0240.01217.86
5.6.50.0290.00417.86
5.6.40.0300.00417.86
5.6.30.0220.01117.86
5.6.20.0230.01517.86
5.6.10.0200.01317.86
5.6.00.0210.01417.86
5.5.380.0240.00717.86
5.5.370.0210.01417.86
5.5.360.0350.00417.86
5.5.350.0200.01217.86
5.5.340.0210.00917.86
5.5.330.0240.01017.86
5.5.320.0320.00917.86
5.5.310.0290.00617.86
5.5.300.0190.01317.86
5.5.290.0260.01217.86
5.5.280.0200.01217.86
5.5.270.0240.01517.86
5.5.260.0280.00717.86
5.5.250.0130.02117.86
5.5.240.0260.00917.86
5.5.230.0180.01817.86
5.5.220.0240.01217.86
5.5.210.0240.01217.86
5.5.200.0200.01317.86
5.5.190.0260.01317.86
5.5.180.0300.00317.86
5.5.170.0250.01117.86
5.5.160.0240.01017.86
5.5.150.0240.01317.86
5.5.140.0210.01117.86
5.5.130.0210.01217.86
5.5.120.0200.01217.86
5.5.110.0270.00817.86
5.5.100.0240.01217.86
5.5.90.0220.00817.86
5.5.80.0160.01617.86
5.5.70.0270.01117.86
5.5.60.0230.01317.86
5.5.50.0370.01017.86
5.5.40.0170.01717.86
5.5.30.0190.01917.86
5.5.20.0240.00717.86
5.5.10.0190.01617.86
5.5.00.0280.00717.86
5.4.450.0200.01317.86
5.4.440.0100.01817.86
5.4.430.0160.00817.86
5.4.420.0120.01217.86
5.4.410.0140.01417.86
5.4.400.0180.00617.86
5.4.390.0240.00417.86
5.4.380.0260.00317.86
5.4.370.0150.01217.86
5.4.360.0150.00817.86
5.4.350.0160.01017.86
5.4.340.0160.01217.86
5.4.330.0180.00917.86
5.4.320.0170.01317.86
5.4.310.0230.00317.86
5.4.300.0140.01017.86
5.4.290.0150.00917.86
5.4.280.0120.01217.86
5.4.270.0210.00617.86
5.4.260.0220.00417.86
5.4.250.0150.01217.86
5.4.240.0090.01517.86
5.4.230.0200.00717.86
5.4.220.0160.01017.86
5.4.210.0190.00717.86
5.4.200.0210.00617.86
5.4.190.0130.01317.86
5.4.180.0250.00017.86
5.4.170.0210.00617.86
5.4.160.0380.01017.86
5.4.150.0200.01017.86
5.4.140.0160.01217.86
5.4.130.0120.01617.86
5.4.120.0240.00017.86
5.4.110.0180.01017.86
5.4.100.0180.00517.86
5.4.90.0170.00917.86
5.4.80.0230.00717.86
5.4.70.0250.00317.86
5.4.60.0190.00617.86
5.4.50.0270.00317.86
5.4.40.0210.00917.86
5.4.30.0190.00817.86
5.4.20.0160.01417.86
5.4.10.0230.00717.86
5.4.00.0240.00317.86
5.3.290.0200.00817.86
5.3.280.0200.00717.86
5.3.270.0160.00917.86
5.3.260.0240.00317.86
5.3.250.0210.00917.86
5.3.240.0210.00917.86
5.3.230.0180.00917.86
5.3.220.0210.00617.86
5.3.210.0150.01517.86
5.3.200.0200.00817.86
5.3.190.0170.01017.86
5.3.180.0180.00717.86
5.3.170.0110.01817.86
5.3.160.0220.00417.86
5.3.150.0170.01217.86
5.3.140.0150.00717.86
5.3.130.0260.00417.86
5.3.120.0220.00617.86
5.3.110.0070.01717.86
5.3.100.0140.01417.86
5.3.90.0260.00317.86
5.3.80.0160.01117.86
5.3.70.0180.00517.86
5.3.60.0220.00617.86
5.3.50.0140.01417.86
5.3.40.0250.00017.86
5.3.30.0190.00717.86
5.3.20.0200.00617.86
5.3.10.0180.01217.86
5.3.00.0180.00617.86
5.2.170.0140.00917.86
5.2.160.0100.01017.86
5.2.150.0150.00817.86
5.2.140.0110.01117.86
5.2.130.0130.01317.86
5.2.120.0190.00417.86
5.2.110.0170.01017.86
5.2.100.0170.00317.86
5.2.90.0140.00717.86
5.2.80.0120.00917.86
5.2.70.0160.00517.86
5.2.60.0130.00517.86
5.2.50.0140.00717.86
5.2.40.0170.00217.86
5.2.30.0170.00317.86
5.2.20.0180.00017.86
5.2.10.0190.00017.86
5.2.00.0130.00717.86
5.1.60.0160.00317.86
5.1.50.0270.01217.86
5.1.40.0120.00817.86
5.1.30.0130.00517.86
5.1.20.0230.00017.86
5.1.10.0120.00917.86
5.1.00.0160.00317.86
5.0.50.0160.00317.86
5.0.40.0100.00717.86
5.0.30.0100.01017.86
5.0.20.0100.00717.86
5.0.10.0110.00417.86
5.0.00.0070.01017.86
4.4.90.0100.00017.86
4.4.80.0060.00317.86
4.4.70.0060.00417.86
4.4.60.0070.00317.86
4.4.50.0110.00017.86
4.4.40.0080.00517.86
4.4.30.0080.00417.86
4.4.20.0090.00317.86
4.4.10.0050.00517.86
4.4.00.0120.00017.86
4.3.110.0090.00317.86
4.3.100.0100.00017.86
4.3.90.0060.00617.86
4.3.80.0080.00317.86
4.3.70.0080.00417.86
4.3.60.0070.00717.86
4.3.50.0100.00217.86
4.3.40.0120.00017.86
4.3.30.0080.00017.86
4.3.20.0080.00017.86
4.3.10.0040.00417.86
4.3.00.0090.00017.86

preferences:
54.61 ms | 400 KiB | 5 Q