3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Change me! $userSpecifiedPath = '/'; // works, HomepageController //$userSpecifiedPath = '/asdf'; // route doesn't exist, 404Controller //$userSpecifiedPath = '/deep/nested/x'; // hierarchy, DeepController // Don't edit below =============================================== // ================================================================ // Simple config example // ================================================================ $routerConfig = <<<CONFIG [/] Controller = "HomepageController" [/deep*] Controller = "DeepController" [404] Controller = "404Controller" CONFIG; // ================================================================ // Simple router example // ================================================================ class Router { private $routes; public function __construct($routes) { $this->routes = $routes; } public function getRouteFromPath($path) { if(array_key_exists($path, $this->routes) === true) { return $this->routes[$path]; } $hierarchical = $this->getHierarchicalRouteFromPath($path); if(!empty($hierarchical)) { return $hierarchical; } elseif(array_key_exists('404', $this->routes) === true) { return $this->routes['404']; } throw new Exception('No controllers found.'); } public function getAllHierarchicalRoutes() { $routes = array(); foreach($this->routes as $key => $route) { if(strpos($key, '*') === strlen($key) - 1) { $routes[$key] = $route; } } return $routes; } public function getHierarchicalRouteFromPath($path) { foreach($this->routes as $key => $route) { if(strpos($key, '*') === strlen($key) - 1) { if(strpos($path, rtrim($key, '*')) === 0) { return $route; } } } } } // ================================================================ // Run example with user-set $userSpecifiedPath // ================================================================ $routes = parse_ini_string($routerConfig, true); $Router = new Router($routes); $selectedRoute = $Router->getRouteFromPath($userSpecifiedPath); echo 'Using controller: ' . $selectedRoute['Controller'];

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.0060.00918.42
8.3.50.0150.00516.45
8.3.40.0080.00818.74
8.3.30.0080.00618.84
8.3.20.0050.00318.77
8.3.10.0030.00518.93
8.3.00.0000.01017.50
8.2.180.0100.01025.92
8.2.170.0100.01018.95
8.2.160.0070.00722.96
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00421.18
8.2.110.0000.00922.29
8.2.100.0120.00017.91
8.2.90.0080.00017.74
8.2.80.0000.00819.41
8.2.70.0090.00017.63
8.2.60.0030.00717.91
8.2.50.0020.00518.03
8.2.40.0040.00419.35
8.2.30.0060.00317.77
8.2.20.0060.00317.64
8.2.10.0000.00817.75
8.2.00.0020.00517.63
8.1.280.0100.01025.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0080.00023.96
8.1.230.0060.00620.85
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0080.00017.38
8.1.180.0070.00319.13
8.1.170.0040.00417.62
8.1.160.0070.00019.03
8.1.150.0040.00418.52
8.1.140.0040.00417.41
8.1.130.0070.00017.47
8.1.120.0060.00317.49
8.1.110.0050.00317.33
8.1.100.0040.00417.45
8.1.90.0040.00417.30
8.1.80.0000.00717.27
8.1.70.0040.00417.42
8.1.60.0030.00517.48
8.1.50.0030.00517.47
8.1.40.0030.00617.60
8.1.30.0000.00917.50
8.1.20.0030.00617.49
8.1.10.0040.00417.50
8.1.00.0080.00017.55
8.0.300.0040.00420.13
8.0.290.0070.00016.88
8.0.280.0070.00018.58
8.0.270.0050.00217.27
8.0.260.0030.00316.80
8.0.250.0000.00717.02
8.0.240.0040.00417.06
8.0.230.0030.00617.01
8.0.220.0040.00417.01
8.0.210.0070.00016.86
8.0.200.0030.00316.91
8.0.190.0000.00717.02
8.0.180.0000.00716.90
8.0.170.0040.00716.96
8.0.160.0070.00017.00
8.0.150.0080.00016.93
8.0.140.0000.00716.87
8.0.130.0030.00313.36
8.0.120.0030.00616.84
8.0.110.0070.00016.71
8.0.100.0030.00516.86
8.0.90.0070.00016.93
8.0.80.0030.01416.94
8.0.70.0040.00416.76
8.0.60.0060.00316.85
8.0.50.0030.00516.73
8.0.30.0140.00617.37
8.0.20.0190.00317.12
8.0.10.0040.00416.99
8.0.00.0120.00616.85
7.4.330.0050.00012.92
7.4.320.0000.00616.61
7.4.300.0030.00316.62
7.4.290.0000.00716.58
7.4.280.0040.00416.61
7.4.270.0040.00416.52
7.4.260.0060.00013.25
7.4.250.0000.00816.51
7.4.240.0000.00816.53
7.4.230.0030.00316.35
7.4.220.0180.00316.62
7.4.210.0090.01216.48
7.4.200.0030.00316.60
7.4.190.0080.00016.72
7.4.160.0100.00716.35
7.4.150.0140.00316.65
7.4.140.0130.00317.86
7.4.130.0160.00816.32
7.4.120.0030.01316.60
7.4.110.0100.00716.57
7.4.100.0060.01016.63
7.4.90.0130.00316.49
7.4.80.0120.00419.39
7.4.70.0080.00816.48
7.4.60.0030.01316.50
7.4.50.0000.00916.56
7.4.40.0060.00816.69
7.4.30.0110.00716.55
7.4.10.0070.01115.16
7.4.00.0080.00914.99
7.3.330.0030.00313.52
7.3.320.0000.00513.45
7.3.310.0000.00716.48
7.3.300.0040.00416.41
7.3.290.0050.01216.42
7.3.280.0100.01016.52
7.3.270.0180.00616.43
7.3.260.0140.00616.32
7.3.240.0070.01016.43
7.3.230.0100.00716.55
7.3.210.0030.01816.46
7.3.200.0080.00816.32
7.3.190.0060.00916.58
7.3.180.0140.00316.49
7.3.170.0030.01516.43
7.3.160.0060.01016.58
7.3.130.0040.01114.90
7.3.120.0070.00914.78
7.3.110.0080.00814.94
7.3.100.0020.00914.79
7.3.90.0040.00814.91
7.3.80.0060.00614.89
7.3.70.0070.00414.95
7.3.60.0030.01214.85
7.3.50.0080.00814.71
7.3.40.0060.00414.62
7.3.30.0060.00914.81
7.3.20.0100.00616.55
7.3.10.0060.00816.50
7.3.00.0090.00816.56
7.2.330.0130.00316.54
7.2.320.0080.00816.49
7.2.310.0110.00616.74
7.2.300.0000.01516.79
7.2.290.0170.00016.60
7.2.260.0160.00314.86
7.2.250.0060.01215.14
7.2.240.0070.01114.95
7.2.230.0060.00814.88
7.2.220.0020.01115.19
7.2.210.0030.00815.07
7.2.200.0090.00514.96
7.2.190.0130.00715.14
7.2.180.0060.00615.29
7.2.170.0050.00815.03
7.2.160.0050.00715.10
7.2.150.0060.00616.89
7.2.140.0080.00516.75
7.2.130.0110.00517.01
7.2.120.0060.00616.80
7.2.110.0080.00616.85
7.2.100.0090.00616.78
7.2.90.0080.00816.77
7.2.80.0050.00816.80
7.2.70.0060.00616.84
7.2.60.0060.00816.86
7.2.50.0050.00816.87
7.2.40.0060.01116.81
7.2.30.0070.00816.89
7.2.20.0080.00816.91
7.2.10.0070.00816.83
7.2.00.0070.01016.98
7.1.330.0080.00515.75
7.1.320.0010.00915.73
7.1.310.0020.01215.74
7.1.300.0040.01115.65
7.1.290.0030.00815.83
7.1.280.0090.00615.67
7.1.270.0030.01015.84
7.1.260.0050.00715.81
7.1.250.0070.01015.78
7.1.240.0060.00515.68
7.1.230.0020.00915.97
7.1.220.0030.00815.64
7.1.210.0050.00815.67
7.1.200.0040.00715.84
7.1.190.0040.00515.83
7.1.180.0060.00715.61
7.1.170.0100.00415.67
7.1.160.0170.00015.85
7.1.150.0080.00815.82
7.1.140.0080.00815.67
7.1.130.0070.00715.87
7.1.120.0560.00315.72
7.1.110.0060.00915.80
7.1.100.0060.00915.82
7.1.90.0100.00515.90
7.1.80.0110.00415.70
7.1.70.0100.00516.29
7.1.60.0050.00816.28
7.1.50.0050.01016.29
7.1.40.0070.00916.13
7.1.30.0040.00816.06
7.1.20.0080.00416.14
7.1.10.0060.00616.01
7.1.00.0060.00516.17
7.0.330.0060.00615.50
7.0.320.0030.00815.22
7.0.310.0020.00615.22
7.0.300.0080.00715.28
7.0.290.0080.00715.51
7.0.280.0100.00415.30
7.0.270.0070.00615.39
7.0.260.0060.00815.14
7.0.250.0090.00515.44
7.0.240.0070.00715.48
7.0.230.0060.00915.34
7.0.220.0120.00215.35
7.0.210.0070.00615.50
7.0.200.0050.00715.86
7.0.190.0070.00615.79
7.0.180.0070.00515.72
7.0.170.0080.00515.69
7.0.160.0040.00715.61
7.0.150.0050.00715.59
7.0.140.0080.00415.63
7.0.130.0060.00615.87
7.0.120.0090.00715.88
7.0.110.0080.00415.63
7.0.100.0050.00715.76
7.0.90.0080.00515.62
7.0.80.0060.00615.75
7.0.70.0040.00915.78
7.0.60.0030.00815.73
7.0.50.0060.00515.88
7.0.40.0070.00514.02
7.0.30.0070.00613.98
7.0.20.0050.00713.98
7.0.10.0070.00613.93
7.0.00.0070.00414.01
5.6.400.0060.00914.27
5.6.390.0000.01514.34
5.6.380.0070.00614.58
5.6.370.0000.01214.67
5.6.360.0070.00714.47
5.6.350.0040.01214.25
5.6.340.0100.00114.59
5.6.330.0070.00714.64
5.6.320.0090.00614.47
5.6.310.0080.00614.49
5.6.300.0040.03416.44
5.6.290.0060.02216.64
5.6.280.0020.02116.70
5.6.270.0040.02316.64
5.6.260.0060.01816.68
5.6.250.0100.01816.52
5.6.240.0080.01616.63
5.6.230.0040.02016.58
5.6.220.0080.01816.56
5.6.210.0080.02716.68
5.6.200.0050.01816.58
5.6.190.0050.02016.61
5.6.180.0060.02016.63
5.6.170.0130.01816.58
5.6.160.0070.01716.56
5.6.150.0070.01916.71
5.6.140.0060.01916.63
5.6.130.0040.02216.55
5.6.120.0070.01716.69
5.6.110.0020.02316.49
5.6.100.0080.01916.47
5.6.90.0080.01616.62
5.6.80.0080.01516.21
5.6.70.0100.02616.27
5.6.60.0050.02216.25
5.6.50.0050.01816.37
5.6.40.0040.02316.43
5.6.30.0050.02316.17
5.6.20.0100.01516.41
5.6.10.0080.01816.31
5.6.00.0070.01716.27
5.5.380.0050.02714.46
5.5.370.0050.01914.50
5.5.360.0050.02114.41
5.5.350.0090.01814.31
5.5.340.0050.02014.47
5.5.330.0080.01514.58
5.5.320.0030.02214.47
5.5.310.0040.02114.65
5.5.300.0060.01914.49
5.5.290.0040.01914.47
5.5.280.0060.01814.44
5.5.270.0030.02014.59
5.5.260.0040.01814.52
5.5.250.0080.01514.48
5.5.240.0060.02614.29
5.5.230.0060.01814.42
5.5.220.0090.01514.32
5.5.210.0050.01914.27
5.5.200.0030.01914.33
5.5.190.0040.02714.25
5.5.180.0050.01814.41
5.5.170.0080.00814.40
5.5.160.0080.01514.42
5.5.150.0020.02114.29
5.5.140.0060.01814.39
5.5.130.0060.01714.33
5.5.120.0040.02014.33
5.5.110.0060.01814.28
5.5.100.0050.01614.23
5.5.90.0090.01514.13
5.5.80.0050.01914.29
5.5.70.0040.01914.23
5.5.60.0060.01614.23
5.5.50.0060.01514.28
5.5.40.0050.01514.28
5.5.30.0040.02114.28
5.5.20.0050.01814.14
5.5.10.0070.01514.25
5.5.00.0020.02214.30
5.4.450.0050.02113.98
5.4.440.0070.01314.07
5.4.430.0060.01413.98
5.4.420.0090.01613.90
5.4.410.0020.02313.98
5.4.400.0020.02013.83
5.4.390.0030.02013.83
5.4.380.0070.01613.89
5.4.370.0020.01813.85
5.4.360.0020.02813.82
5.4.350.0050.01713.94
5.4.340.0070.01913.83
5.4.330.0050.00511.22
5.4.320.0060.01913.83
5.4.310.0050.01513.96
5.4.300.0020.02013.89
5.4.290.0040.01913.94
5.4.280.0040.01913.87
5.4.270.0050.01713.88
5.4.260.0070.01513.80
5.4.250.0040.01813.91
5.4.240.0030.01713.89
5.4.230.0070.01613.95
5.4.220.0040.01713.78
5.4.210.0040.01613.82
5.4.200.0080.01513.84
5.4.190.0050.01713.83
5.4.180.0070.01313.85
5.4.170.0050.01613.92
5.4.160.0060.01713.88
5.4.150.0030.01713.86
5.4.140.0080.01413.09
5.4.130.0040.01613.07
5.4.120.0060.01412.99
5.4.110.0060.01413.05
5.4.100.0030.01713.07
5.4.90.0050.01613.04
5.4.80.0050.01513.09
5.4.70.0090.01913.13
5.4.60.0080.01613.02
5.4.50.0070.01712.97
5.4.40.0030.01713.06
5.4.30.0030.01813.08
5.4.20.0030.01513.03
5.4.10.0040.01613.12
5.4.00.0040.01812.88
5.3.290.0040.01812.55
5.3.280.0060.01512.55
5.3.270.0050.01612.55
5.3.260.0050.01612.55
5.3.250.0050.01512.55
5.3.240.0010.02012.55
5.3.230.0050.01612.55
5.3.220.0050.01512.55
5.3.210.0040.01612.55
5.3.200.0040.01712.55
5.3.190.0080.01512.55
5.3.180.0050.01612.55
5.3.170.0050.01612.55
5.3.160.0060.01512.55
5.3.150.0050.02212.55
5.3.140.0020.01612.55
5.3.130.0020.01812.55
5.3.120.0020.01712.55
5.3.110.0070.01212.55
5.3.100.0040.01712.55
5.3.90.0070.01412.55
5.3.80.0060.01412.55
5.3.70.0050.02112.55
5.3.60.0040.01512.55
5.3.50.0030.01412.55
5.3.40.0040.02512.55
5.3.30.0030.01612.55
5.3.20.0030.01512.55
5.3.10.0010.01612.55
5.3.00.0020.01712.55
5.2.170.0060.02813.14
5.2.160.0050.01813.14
5.2.150.0040.03413.14
5.2.140.0030.01913.14
5.2.130.0060.02413.14
5.2.120.0020.01913.14
5.2.110.0010.02113.14
5.2.100.0070.01513.14
5.2.90.0060.01613.14
5.2.80.0020.01913.14
5.2.70.0120.01113.14
5.2.60.0000.03113.14
5.2.50.0040.02413.14
5.2.40.0040.01813.14
5.2.30.0070.01513.14
5.2.20.0070.01313.14
5.2.10.0070.01713.14
5.2.00.0040.01913.14
5.1.60.0040.01413.14
5.1.50.0050.02313.14
5.1.40.0040.01613.14
5.1.30.0050.01513.14
5.1.20.0020.01813.14
5.1.10.0030.02013.14
5.1.00.0020.01713.14
5.0.50.0020.01513.14
5.0.40.0020.01413.14
5.0.30.0040.01713.14
5.0.20.0030.01413.14
5.0.10.0040.02513.14
5.0.00.0050.03113.14
4.4.90.0070.01313.14
4.4.80.0030.01113.14
4.4.70.0030.01913.14
4.4.60.0000.01213.14
4.4.50.0040.01113.14
4.4.40.0020.01913.14
4.4.30.0010.00913.14
4.4.20.0020.01013.14
4.4.10.0020.01913.14
4.4.00.0060.02713.14
4.3.110.0040.00613.14
4.3.100.0040.01113.14
4.3.90.0020.01313.14
4.3.80.0020.01713.14
4.3.70.0050.00713.14
4.3.60.0030.01113.14
4.3.50.0030.00813.14
4.3.40.0020.01613.14
4.3.30.0050.01113.14
4.3.20.0010.01013.14
4.3.10.0030.00913.14
4.3.00.0050.01513.14

preferences:
43.03 ms | 401 KiB | 5 Q