3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Request { private $method; private $path; function __construct($method, $path) { $this->method = $method; $this->path = $path; } function getMethod() { return $this->method; } function getPath() { return $this->path; } } class Router { private $routes = [ 'get' => [], 'post' => [] ]; function get($pattern, callable $handler) { $this->routes['get'][$pattern] = $handler; return $this; } function post($pattern, callable $handler) { $this->routes['post'][$pattern] = $handler; return $this; } function match(Request $request) { $method = strtolower($request->getMethod()); if (!isset($this->routes[$method])) { return false; } $path = $request->getPath(); foreach ($this->routes[$method] as $pattern => $handler) { if ($pattern === $path) { return $handler; } } return false; } } class Dispatcher { private $router; function __construct(Router $router) { $this->router = $router; } function handle(Request $request) { $handler = $this->router->match($request); if (!$handler) { echo "Could not find your resource!\n"; return; } $handler(); } } $router = new Router(); $router->get('foo', function() { echo "GET foo\n"; }); $router->post('bar', function() { echo "POST bar\n"; }); $dispatcher = new Dispatcher($router); $foo = new Request('GET', 'foo'); $bar = new Request('POST', 'bar'); $qux = new Request('GET', 'qux'); $dispatcher->handle($foo); $dispatcher->handle($bar); $dispatcher->handle($qux);

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.0040.01116.50
8.3.50.0130.00822.10
8.3.40.0150.00618.82
8.3.30.0100.00319.23
8.3.20.0050.00320.29
8.3.10.0030.00623.69
8.3.00.0080.00019.50
8.2.180.0090.01318.18
8.2.170.0210.00022.96
8.2.160.0100.00720.52
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0070.00726.16
8.2.120.0040.00422.12
8.2.110.0030.00622.21
8.2.100.0080.00417.72
8.2.90.0080.00019.20
8.2.80.0030.00617.97
8.2.70.0030.00517.63
8.2.60.0040.00417.93
8.2.50.0030.00618.07
8.2.40.0000.00919.89
8.2.30.0070.00018.12
8.2.20.0050.00317.81
8.2.10.0040.00418.27
8.2.00.0000.00917.66
8.1.280.0110.00825.92
8.1.270.0080.00023.96
8.1.260.0050.00326.35
8.1.250.0060.00328.09
8.1.240.0060.00323.91
8.1.230.0090.00319.04
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0050.00517.35
8.1.190.0000.00817.35
8.1.180.0030.00618.10
8.1.170.0000.01018.44
8.1.160.0040.00422.03
8.1.150.0080.00018.57
8.1.140.0050.00217.39
8.1.130.0030.00317.84
8.1.120.0000.00717.47
8.1.110.0030.00517.39
8.1.100.0080.00017.41
8.1.90.0070.00017.33
8.1.80.0060.00317.47
8.1.70.0030.00317.39
8.1.60.0030.00617.56
8.1.50.0080.00017.41
8.1.40.0030.00617.43
8.1.30.0050.00317.58
8.1.20.0000.00817.67
8.1.10.0000.00817.62
8.1.00.0070.00017.56
8.0.300.0070.00018.77
8.0.290.0000.00717.05
8.0.280.0030.00318.46
8.0.270.0040.00417.18
8.0.260.0000.00717.32
8.0.250.0030.00317.05
8.0.240.0050.00316.97
8.0.230.0040.00417.05
8.0.220.0000.00816.87
8.0.210.0030.00316.84
8.0.200.0030.00616.99
8.0.190.0050.00317.09
8.0.180.0000.00916.88
8.0.170.0000.00816.88
8.0.160.0000.00716.95
8.0.150.0000.00716.81
8.0.140.0020.00516.92
8.0.130.0000.00513.46
8.0.120.0040.00416.91
8.0.110.0000.00716.86
8.0.100.0070.00016.84
8.0.90.0080.00017.09
8.0.80.0110.00717.02
8.0.70.0000.00716.77
8.0.60.0050.00216.87
8.0.50.0000.00817.01
8.0.30.0090.01117.09
8.0.20.0100.00817.40
8.0.10.0040.00417.15
8.0.00.0120.00916.72
7.4.330.0000.00515.00
7.4.320.0030.00316.63
7.4.300.0030.00316.47
7.4.290.0050.00316.54
7.4.280.0050.00216.51
7.4.270.0030.00316.53
7.4.260.0040.00416.50
7.4.250.0000.00916.58
7.4.240.0010.00616.51
7.4.230.0040.00416.52
7.4.220.0070.01116.73
7.4.210.0070.00916.59
7.4.200.0000.00716.36
7.4.190.0050.00316.68
7.4.160.0130.00316.43
7.4.150.0040.01817.40
7.4.140.0090.01017.86
7.4.130.0090.00916.53
7.4.120.0120.00616.46
7.4.110.0080.01616.73
7.4.100.0090.00916.57
7.4.90.0080.00816.43
7.4.80.0100.00719.39
7.4.70.0110.00816.41
7.4.60.0070.01016.53
7.4.50.0000.00416.33
7.4.40.0100.00616.55
7.4.30.0070.01016.45
7.4.10.0080.01115.08
7.4.00.0070.00915.00
7.3.330.0030.00313.41
7.3.320.0030.00313.36
7.3.310.0000.00716.41
7.3.300.0000.00716.38
7.3.290.0090.01016.38
7.3.280.0090.00716.35
7.3.270.0100.00717.40
7.3.260.0100.01416.39
7.3.250.0090.00816.47
7.3.240.0150.00616.28
7.3.230.0080.00916.39
7.3.210.0070.01016.30
7.3.200.0000.01819.39
7.3.190.0120.00916.56
7.3.180.0070.01016.58
7.3.170.0070.01416.66
7.3.160.0160.00016.58
7.3.130.0070.00715.05
7.3.120.0060.01114.75
7.3.110.0050.01415.10
7.3.100.0100.00314.94
7.3.90.0060.00914.96
7.3.80.0040.00615.04
7.3.70.0020.01014.84
7.3.60.0060.00914.87
7.3.50.0070.00814.74
7.3.40.0050.00814.98
7.3.30.0050.00814.79
7.3.20.0030.00916.74
7.3.10.0030.00716.69
7.3.00.0070.00616.63
7.2.330.0030.01416.69
7.2.320.0150.00616.55
7.2.310.0070.01016.71
7.2.300.0070.01016.51
7.2.290.0140.00416.59
7.2.260.0110.00714.83
7.2.250.0070.01015.21
7.2.240.0080.00815.26
7.2.230.0020.01415.19
7.2.220.0050.00915.32
7.2.210.0020.01115.17
7.2.200.0090.00614.95
7.2.190.0060.00615.11
7.2.180.0040.01314.98
7.2.170.0050.00915.28
7.2.160.0090.00615.11
7.2.150.0090.00317.11
7.2.140.0090.00917.01
7.2.130.0100.00316.94
7.2.120.0100.00317.06
7.2.110.0060.01616.90
7.2.100.0070.01016.97
7.2.90.0040.00817.07
7.2.80.0070.00716.90
7.2.70.0070.00716.88
7.2.60.0050.01216.98
7.2.50.0120.00016.64
7.2.40.0030.01316.89
7.2.30.0140.00317.09
7.2.20.0060.00916.99
7.2.10.0060.00616.91
7.2.00.0020.01218.28
7.1.330.0050.01015.94
7.1.320.0050.01015.96
7.1.310.0010.01015.93
7.1.300.0050.00815.92
7.1.290.0050.00715.83
7.1.280.0030.00915.68
7.1.270.0040.00715.78
7.1.260.0030.01015.79
7.1.250.0000.01215.95
7.1.240.0070.01015.93
7.1.230.0060.00915.88
7.1.220.0030.01515.73
7.1.210.0040.01115.49
7.1.200.0070.00615.81
7.1.190.0040.01415.83
7.1.180.0070.00715.78
7.1.170.0040.01115.89
7.1.160.0030.01515.62
7.1.150.0090.00615.69
7.1.140.0060.00915.67
7.1.130.0040.01116.01
7.1.120.0110.00415.59
7.1.110.0070.01015.98
7.1.100.0060.01016.89
7.1.90.0000.01115.91
7.1.80.0070.00715.78
7.1.70.0090.00116.54
7.1.60.0080.01017.63
7.1.50.0030.01516.44
7.1.40.0000.01015.58
7.1.30.0030.01315.67
7.1.20.0060.00615.93
7.1.10.0070.00715.91
7.1.00.0110.03319.02
7.0.330.0060.00315.44
7.0.320.0000.01215.50
7.0.310.0100.00315.53
7.0.300.0000.01415.44
7.0.290.0090.00915.60
7.0.280.0070.00715.18
7.0.270.0050.00915.40
7.0.260.0040.01115.47
7.0.250.0100.00315.47
7.0.240.0030.00615.29
7.0.230.0000.01315.47
7.0.220.0040.01115.48
7.0.210.0040.01215.58
7.0.200.0050.00615.96
7.0.190.0080.00015.50
7.0.180.0060.00615.62
7.0.170.0070.00715.21
7.0.160.0030.00915.36
7.0.150.0060.00915.43
7.0.140.0040.03918.82
7.0.130.0070.00715.51
7.0.120.0040.00815.43
7.0.110.0030.01015.35
7.0.100.0060.00615.34
7.0.90.0040.01115.33
7.0.80.0000.00815.27
7.0.70.0060.00615.59
7.0.60.0100.04017.74
7.0.50.0040.04216.65
7.0.40.0100.04017.07
7.0.30.0170.04217.04
7.0.20.0150.04417.01
7.0.10.0140.04717.04
7.0.00.0030.03217.05
5.6.400.0060.00914.57
5.6.390.0100.00314.53
5.6.380.0000.01414.64
5.6.370.0060.00914.32
5.6.360.0000.01814.78
5.6.350.0070.01014.34
5.6.340.0070.01014.38
5.6.330.0000.01514.29
5.6.320.0030.01214.41
5.6.310.0060.00914.67
5.6.300.0100.00314.25
5.6.290.0100.00014.85
5.6.280.0090.04817.69
5.6.270.0000.01414.81
5.6.260.0040.00414.53
5.6.250.0040.01114.41
5.6.240.0070.01014.53
5.6.230.0100.00314.42
5.6.220.0070.00714.26
5.6.210.0060.04417.57
5.6.200.0060.04316.21
5.6.190.0050.02517.54
5.6.180.0080.04317.54
5.6.170.0240.03717.46
5.6.160.0120.02317.55
5.6.150.0050.02516.39
5.6.140.0080.02716.21
5.6.130.0060.03016.45
5.6.120.0100.03617.54
5.6.110.0100.02017.74
5.6.100.0040.03917.87
5.6.90.0120.03217.56
5.6.80.0050.04517.41
5.6.70.0160.04117.35
5.6.60.0060.00914.71
5.6.50.0070.00314.54
5.6.40.0060.00314.18
5.6.30.0120.00314.30
5.6.20.0070.00714.30
5.6.10.0060.00914.61
5.6.00.0090.00914.44
5.5.380.0030.00614.71
5.5.370.0050.00514.66
5.5.360.0040.00814.06
5.5.350.0050.03017.50
5.5.340.0050.03116.10
5.5.330.0050.03017.41
5.5.320.0020.02817.50
5.5.310.0200.03017.40
5.5.300.0080.02016.22
5.5.290.0060.04316.29
5.5.280.0030.05017.70
5.5.270.0050.02517.74
5.5.260.0070.02417.59
5.5.250.0130.03317.40
5.5.240.0110.04017.36
5.5.230.0000.01114.36
5.5.220.0000.01414.40
5.5.210.0080.00814.49
5.5.200.0050.00514.29
5.5.190.0080.00014.42
5.5.180.0040.01114.21
5.5.170.0070.00714.23
5.5.160.0100.00014.52
5.5.150.0000.01314.58
5.5.140.0090.00914.10
5.5.130.0070.01114.25
5.5.120.0090.00614.42
5.5.110.0000.01214.44
5.5.100.0040.00814.32
5.5.90.0070.00314.43
5.5.80.0040.01214.07
5.5.70.0080.00414.19
5.5.60.0060.00914.47
5.5.50.0060.00614.50
5.5.40.0100.00314.27
5.5.30.0060.00914.47
5.5.20.0030.00714.11
5.5.10.0030.01214.34
5.5.00.0090.00314.43
5.4.450.0410.03516.75
5.4.440.0220.03216.55
5.4.430.0430.02616.68
5.4.420.0330.00316.66
5.4.410.0070.03216.49
5.4.400.0120.02716.36
5.4.390.0160.02616.21
5.4.380.0180.04016.25
5.4.370.0080.02316.33
5.4.360.0080.02316.34
5.4.350.0050.02512.97
5.4.340.0050.02212.96
5.4.330.0030.00913.89
5.4.320.0060.03113.21
5.4.310.0040.02713.21
5.4.300.0050.02413.21
5.4.290.0070.03213.21
5.4.280.0080.03113.16
5.4.270.0040.03313.16
5.4.260.0090.02313.16
5.4.250.0070.02813.15
5.4.240.0070.03113.16
5.4.230.0090.03413.15
5.4.220.0080.03713.15
5.4.210.0100.03013.15
5.4.200.0160.04913.15
5.4.190.0110.04213.15
5.4.180.0060.03013.15
5.4.170.0100.02913.15
5.4.160.0040.03613.15
5.4.150.0070.03113.15
5.4.140.0060.03712.99
5.4.130.0110.03112.99
5.4.120.0040.03312.96
5.4.110.0040.03112.96
5.4.100.0050.03112.96
5.4.90.0080.03012.96
5.4.80.0100.03812.96
5.4.70.0090.02712.96
5.4.60.0060.03012.96
5.4.50.0070.03012.96
5.4.40.0080.02812.96
5.4.30.0120.02312.95
5.4.20.0060.02712.95
5.4.10.0090.02712.95
5.4.00.0080.03212.70
5.3.290.0070.02013.35
5.3.280.0140.02913.30
5.3.270.0110.03213.31
5.3.260.0150.03113.31
5.3.250.0090.03813.30
5.3.240.0080.03313.31
5.3.230.0120.03013.30
5.3.220.0100.03013.29
5.3.210.0090.03913.29
5.3.200.0070.03213.29
5.3.190.0110.03813.29
5.3.180.0120.04913.28
5.3.170.0130.04013.28
5.3.160.0100.06313.28
5.3.150.0080.03613.28
5.3.140.0130.04713.28
5.3.130.0070.03513.28
5.3.120.0060.03413.28
5.3.110.0060.03213.28
5.3.100.0060.03213.01
5.3.90.0050.03513.00
5.3.80.0080.03713.00
5.3.70.0060.03513.00
5.3.60.0090.02512.99
5.3.50.0040.03012.96
5.3.40.0070.02712.96
5.3.30.0060.03012.94
5.3.20.0050.03012.83
5.3.10.0070.02812.82
5.3.00.0100.02612.81
5.2.170.0090.0439.23
5.2.160.0080.0429.23
5.2.150.0080.0429.23
5.2.140.0060.0399.22
5.2.130.0050.0369.18
5.2.120.0040.0359.18
5.2.110.0050.0319.19
5.2.100.0070.0419.19
5.2.90.0130.0369.19
5.2.80.0060.0439.18
5.2.70.0060.0439.18
5.2.60.0090.0409.14
5.2.50.0040.0449.11
5.2.40.0060.0399.09
5.2.30.0080.0419.06
5.2.20.0070.0439.05
5.2.10.0080.0378.95
5.2.00.0100.0388.82
5.1.60.0070.0358.10
5.1.50.0100.0318.09
5.1.40.0060.0398.07
5.1.30.0120.0368.43
5.1.20.0080.0398.44
5.1.10.0080.0338.17
5.1.00.0060.0368.18
5.0.50.0060.0316.64
5.0.40.0050.0276.52
5.0.30.0070.0406.32
5.0.20.0050.0276.29
5.0.10.0120.0216.27
5.0.00.0070.0386.26
4.4.90.0040.0224.78
4.4.80.0040.0224.76
4.4.70.0040.0264.75
4.4.60.0030.0234.76
4.4.50.0080.0184.77
4.4.40.0020.0364.71
4.4.30.0070.0184.76
4.4.20.0040.0234.85
4.4.10.0010.0264.85
4.4.00.0050.0334.76
4.3.110.0050.0224.67
4.3.100.0030.0234.66
4.3.90.0070.0214.63
4.3.80.0020.0364.58
4.3.70.0030.0244.63
4.3.60.0060.0204.63
4.3.50.0020.0264.63
4.3.40.0050.0334.54
4.3.30.0020.0223.30
4.3.20.0040.0363.28
4.3.10.0040.0213.23
4.3.00.0130.0237.62

preferences:
48.24 ms | 401 KiB | 5 Q