3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Because PHP_URL_* constants are sequential :-( const URL_SCHEME = 0x01; const URL_USER = 0x02; const URL_PASS = 0x04; const URL_HOST = 0x08; const URL_PORT = 0x10; const URL_PATH = 0x20; const URL_QUERY = 0x40; const URL_FRAGMENT = 0x80; function url_replace($url, $components, callable $callback) { $map = [ URL_SCHEME => 'scheme', URL_USER => 'user', URL_PASS => 'pass', URL_HOST => 'host', URL_PORT => 'port', URL_PATH => 'path', URL_QUERY => 'query', URL_FRAGMENT => 'fragment', ]; if (!$parts = parse_url($url)) { return $url; } foreach ($map as $component => $key) { if ($components & $component) { $parts[$key] = $callback($parts[$key], $component); } } $result = ''; if (isset($parts['scheme'])) { $result = $parts['scheme'] . ':'; } if (isset($parts['host'])) { $result .= '//'; if (isset($parts['user'])) { $result .= $parts['user']; if (isset($parts['pass'])) { $result .= ':' . $parts['pass']; } $result .= '@'; } $result .= $parts['host']; if (isset($parts['port'])) { $result .= ':' . $parts['port']; } } if (isset($parts['path'])) { $result .= $parts['path']; } if (isset($parts['query'])) { $result .= $parts['query']; } if (isset($parts['fragment'])) { $result .= $parts['fragment']; } return $result; } $url = 'http://test.com/test-one,two three?a=b#bla'; echo url_replace($url, URL_PATH, function($path) { return '/foobar'; });

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.0130.00616.75
8.3.50.0100.00318.08
8.3.40.0100.00318.80
8.3.30.0110.00418.95
8.3.20.0090.00020.34
8.3.10.0070.00022.10
8.3.00.0080.00022.34
8.2.180.0130.01016.50
8.2.170.0130.00722.96
8.2.160.0120.00320.86
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00417.75
8.2.110.0100.01621.07
8.2.100.0110.00019.57
8.2.90.0030.00519.08
8.2.80.0000.00817.97
8.2.70.0030.00617.75
8.2.60.0030.00617.93
8.2.50.0040.00418.10
8.2.40.0000.00818.28
8.2.30.0000.00718.03
8.2.20.0000.00817.79
8.2.10.0040.00419.42
8.2.00.0040.00417.76
8.1.270.0060.00323.96
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00322.66
8.1.230.0100.00017.96
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0030.00617.38
8.1.190.0050.00317.22
8.1.180.0040.00418.10
8.1.170.0000.00818.62
8.1.160.0070.00321.95
8.1.150.0000.00718.58
8.1.140.0040.00417.48
8.1.130.0070.00017.76
8.1.120.0040.00417.51
8.1.110.0040.00417.46
8.1.100.0040.00417.54
8.1.90.0040.00417.43
8.1.80.0040.00417.50
8.1.70.0070.00017.48
8.1.60.0030.00517.60
8.1.50.0040.00417.41
8.1.40.0040.00417.44
8.1.30.0030.00517.65
8.1.20.0040.00417.66
8.1.10.0090.00017.49
8.1.00.0030.00617.57
8.0.300.0000.00818.77
8.0.290.0070.00316.88
8.0.280.0080.00018.38
8.0.270.0000.00717.34
8.0.260.0030.00316.95
8.0.250.0070.00017.05
8.0.240.0000.01116.94
8.0.230.0030.00316.93
8.0.220.0030.00317.04
8.0.210.0000.00716.89
8.0.200.0000.00617.04
8.0.190.0000.00816.96
8.0.180.0040.00416.98
8.0.170.0000.00916.90
8.0.160.0040.00417.02
8.0.150.0080.00016.89
8.0.140.0030.00616.92
8.0.130.0030.00613.35
8.0.120.0040.00417.00
8.0.110.0050.00216.98
8.0.100.0000.00816.94
8.0.90.0000.00717.03
8.0.80.0080.00817.05
8.0.70.0040.00416.99
8.0.60.0000.00716.81
8.0.50.0040.00416.80
8.0.30.0150.00617.29
8.0.20.0130.00617.40
8.0.10.0030.00517.08
8.0.00.0090.01016.90
7.4.330.0050.00015.07
7.4.320.0000.00616.64
7.4.300.0000.00716.43
7.4.290.0030.00516.65
7.4.280.0030.00516.43
7.4.270.0000.00716.55
7.4.260.0000.00716.54
7.4.250.0000.00716.61
7.4.240.0050.00316.61
7.4.230.0030.00316.41
7.4.220.0190.00016.71
7.4.210.0060.00916.53
7.4.200.0070.00016.37
7.4.190.0000.00716.57
7.4.160.0080.00816.52
7.4.150.0090.01017.40
7.4.140.0050.01217.86
7.4.130.0100.01116.53
7.4.120.0080.01016.52
7.4.110.0140.00316.45
7.4.100.0140.00416.58
7.4.90.0060.01216.55
7.4.80.0030.01516.55
7.4.70.0090.01516.59
7.4.60.0060.01016.51
7.4.50.0030.00516.45
7.4.40.0060.00622.77
7.4.30.0130.00316.61
7.4.00.0030.01214.70
7.3.330.0000.00513.46
7.3.320.0060.00013.21
7.3.310.0070.00016.42
7.3.300.0070.00016.31
7.3.290.0100.00316.39
7.3.280.0080.00816.42
7.3.270.0040.01417.40
7.3.260.0090.00916.66
7.3.250.0090.01016.46
7.3.240.0110.00616.45
7.3.230.0100.00716.52
7.3.210.0090.00916.41
7.3.200.0090.01519.39
7.3.190.0100.01016.67
7.3.180.0090.01216.68
7.3.170.0110.00416.46
7.3.160.0100.00516.41
7.3.120.0090.00614.95
7.2.330.0070.01016.86
7.2.320.0120.01016.76
7.2.310.0000.01616.82
7.2.300.0130.00416.82
7.2.290.0100.00616.64
7.2.60.0060.00616.99
7.1.200.0110.00015.82
7.1.70.0040.00416.98
7.1.60.0000.02519.82
7.1.50.0070.01417.00
7.1.00.0000.08022.33
7.0.200.0340.00014.83
7.0.140.0000.07321.98
7.0.60.0100.03719.98
7.0.50.0030.04317.86
7.0.40.0130.05720.40
7.0.30.0230.04720.05
7.0.20.0270.05020.10
7.0.10.0100.04720.30
7.0.00.0030.05020.29
5.6.280.0030.07321.18
5.6.210.0200.06020.57
5.6.200.0030.08718.19
5.6.190.0170.03020.47
5.6.180.0000.04320.53
5.6.170.0230.06320.57
5.6.160.0100.04020.54
5.6.150.0030.04018.18
5.6.140.0100.04318.19
5.6.130.0100.07018.27
5.6.120.0070.08321.04
5.6.110.0070.06021.01
5.6.100.0030.06721.07
5.6.90.0070.08021.01
5.6.80.0030.08320.43
5.6.70.0330.06720.38
5.5.350.0070.07720.38
5.5.340.0070.08018.00
5.5.330.0130.08320.35
5.5.320.0300.07320.30
5.5.310.0300.06320.24
5.5.300.0000.06718.04
5.5.290.0200.06017.91
5.5.280.0070.03720.79
5.5.270.0130.07720.89
5.5.260.0070.04020.78
5.5.250.0030.08320.60
5.5.240.0030.04320.21
5.4.450.0530.04319.30
5.4.440.0830.03019.31
5.4.430.0030.05319.56
5.4.420.0630.04319.46
5.4.410.0730.03719.15
5.4.400.0200.04719.00
5.4.390.0500.05019.22
5.4.380.0370.06018.73
5.4.370.0500.04318.74
5.4.360.0270.06318.83
5.4.350.0370.05018.74
5.4.340.0330.05318.71
5.4.320.0050.04112.52
5.4.310.0060.03812.52
5.4.300.0070.03612.52
5.4.290.0070.04312.52
5.4.280.0070.03712.42
5.4.270.0080.04112.41
5.4.260.0070.04012.41
5.4.250.0060.03812.41
5.4.240.0040.03812.41
5.4.230.0040.04612.41
5.4.220.0090.03412.41
5.4.210.0050.04312.41
5.4.200.0060.03912.41
5.4.190.0150.04612.40
5.4.180.0140.04412.40
5.4.170.0150.04212.41
5.4.160.0140.04512.40
5.4.150.0270.06812.40
5.4.140.0190.04012.09
5.4.130.0190.04112.07
5.4.120.0160.04512.03
5.4.110.0190.04312.02
5.4.100.0180.05212.02
5.4.90.0150.04512.03
5.4.80.0230.09912.03
5.4.70.0190.03812.02
5.4.60.0210.03512.02
5.4.50.0140.04612.02
5.4.40.0270.06212.01
5.4.30.0140.04512.00
5.4.20.0180.03812.00
5.4.10.0150.04612.00
5.4.00.0160.04111.49
5.3.290.0050.04012.80
5.3.280.0050.04112.71
5.3.270.0220.04212.72
5.3.260.0160.04612.72
5.3.250.0230.03912.72
5.3.240.0130.04812.72
5.3.230.0240.07212.70
5.3.220.0120.05012.68
5.3.210.0220.04212.68
5.3.200.0140.04712.68
5.3.190.0170.04412.68
5.3.180.0160.04712.68
5.3.170.0180.04212.67
5.3.160.0060.05412.68
5.3.150.0080.05212.67
5.3.140.0170.04512.66
5.3.130.0140.05012.66
5.3.120.0170.04812.65
5.3.110.0180.04712.66
5.3.100.0170.05412.11
5.3.90.0450.08612.11
5.3.80.0240.06912.09
5.3.70.0210.04312.09
5.3.60.0140.04912.07
5.3.50.0170.04512.02
5.3.40.0170.04812.02
5.3.30.0210.05712.00
5.3.20.0330.09011.77
5.3.10.0210.04211.72
5.3.00.0170.04311.71
5.2.170.0180.0329.19
5.2.160.0150.0349.18
5.2.150.0140.0349.18
5.2.140.0210.0599.18
5.2.130.0100.0399.14
5.2.120.0150.0369.14
5.2.110.0120.0369.15
5.2.100.0110.0389.15
5.2.90.0200.0579.15
5.2.80.0140.0329.13
5.2.70.0120.0369.13
5.2.60.0210.0569.09
5.2.50.0160.0349.05
5.2.40.0140.0369.04
5.2.30.0180.0289.01
5.2.20.0130.0369.00
5.2.10.0140.0328.93
5.2.00.0140.0338.78
5.1.60.0080.0328.07
5.1.50.0100.0318.06
5.1.40.0170.0318.05
5.1.30.0120.0358.39
5.1.20.0100.0358.43
5.1.10.0120.0348.14
5.1.00.0110.0328.14
5.0.50.0080.0266.63
5.0.40.0060.0266.48
5.0.30.0250.0796.30
5.0.20.0110.0206.27
5.0.10.0110.0216.25
5.0.00.0080.0366.24
4.4.90.0060.0204.78
4.4.80.0080.0174.75
4.4.70.0070.0204.75
4.4.60.0070.0184.75
4.4.50.0110.0154.77
4.4.40.0090.0264.71
4.4.30.0070.0184.76
4.4.20.0040.0214.85
4.4.10.0080.0174.85
4.4.00.0040.0334.75
4.3.110.0070.0214.67
4.3.100.0050.0224.67
4.3.90.0090.0194.64
4.3.80.0100.0264.58
4.3.70.0060.0194.63
4.3.60.0110.0164.63
4.3.50.0070.0204.63
4.3.40.0060.0284.54
4.3.30.0050.0183.29
4.3.20.0050.0183.27
4.3.10.0040.0223.23
4.3.00.0000.01715.18

preferences:
54.82 ms | 400 KiB | 5 Q