3v4l.org

run code in 300+ PHP versions simultaneously
<?php function redirect($url = '', array $params = array()) { // スキーム省略に対応 $url = preg_replace_callback( '@^/{2}(?!/)@', function ($matches) { return empty($_SERVER['HTTPS']) || strcasecmp($_SERVER['HTTPS'], 'off') ? 'http://' : 'https://' ; }, $url ); // URLをパースする if (!$p = parse_url($url)) { throw new BadMethodCallException('URLのパースに失敗しました'); } // 相対URLで書かれた場合には絶対URLに補正して再パースさせる if (!isset($p['host'])) { $url = rtrim($GLOBALS['SITE_URL'], '/') . '/' . ltrim($url, '/'); if (!$p = parse_url($url) or !isset($p['host']) or !isset($p['scheme'])) { throw new BadMethodCallException('URLのパースに失敗しました'); } } // クエリ―ストリングをパースして連想配列にする parse_str(isset($p['query']) ? $p['query'] : '', $query); // URLを組み立てていく $user_and_pass[] = isset($p['user']) ? $p['user'] : null; $user_and_pass[] = isset($p['pass']) ? $p['pass'] : null; $host_and_port[] = $p['host']; $host_and_port[] = isset($p['port']) ? $p['port'] : null; $server[] = implode(':', array_filter($user_and_pass, 'is_scalar')); $server[] = implode(':', array_filter($host_and_port, 'is_scalar')); $server_and_path[] = implode('@', array_filter($server, 'strlen')); $server_and_path[] = isset($p['path']) ? ltrim($p['path'], '/') : ''; $sp_and_query[] = implode('/', $server_and_path); $sp_and_query[] = http_build_query($params + $query, '', '&'); $spq_and_fragment[] = implode('?', array_filter($sp_and_query, 'strlen')); $spq_and_fragment[] = isset($p['fragment']) ? $p['fragment'] : null; $scheme_and_spqf[] = $p['scheme']; $scheme_and_spqf[] = implode('#', array_filter($spq_and_fragment, 'is_scalar')); $url = implode('://', $scheme_and_spqf); // 改行コードやNULLバイトを削除する $url = str_replace(array("\r", "\n", "\0"), '', $url); return $url; } $SITE_URL = 'http://user:' . "\n\0\n" . 'pass@exam' . "\n" . 'ple.com:87/p'."\n".'ublic'; var_dump(redirect("\n" . '//test.php?a=b'));

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.48
8.3.50.0100.00722.24
8.3.40.0040.01118.92
8.3.30.0030.01019.18
8.3.20.0040.00420.29
8.3.10.0030.00721.92
8.3.00.0050.00322.46
8.2.180.0030.01716.75
8.2.170.0070.01422.96
8.2.160.0070.01119.24
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0100.00326.16
8.2.120.0080.00019.86
8.2.110.0060.00322.25
8.2.100.0080.00418.03
8.2.90.0000.00919.23
8.2.80.0080.00017.97
8.2.70.0030.00717.88
8.2.60.0000.00818.05
8.2.50.0050.00318.07
8.2.40.0080.00018.28
8.2.30.0040.00418.08
8.2.20.0030.00517.98
8.2.10.0030.00518.00
8.2.00.0040.00418.00
8.1.280.0140.00025.92
8.1.270.0020.00522.31
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0050.00523.85
8.1.230.0080.00319.13
8.1.220.0000.00917.74
8.1.210.0030.00618.77
8.1.200.0080.00417.60
8.1.190.0030.00517.63
8.1.180.0060.00318.96
8.1.170.0030.00518.82
8.1.160.0000.00722.25
8.1.150.0020.00518.75
8.1.140.0000.00717.77
8.1.130.0070.00017.85
8.1.120.0040.00417.67
8.1.110.0080.00017.54
8.1.100.0070.00017.63
8.1.90.0070.00017.62
8.1.80.0000.00717.54
8.1.70.0000.00817.61
8.1.60.0030.00617.70
8.1.50.0030.00517.67
8.1.40.0040.00417.73
8.1.30.0040.00417.78
8.1.20.0050.00317.87
8.1.10.0040.00417.76
8.1.00.0080.00317.71
8.0.300.0040.00418.77
8.0.290.0080.00017.16
8.0.280.0070.00018.52
8.0.270.0040.00417.23
8.0.260.0070.00017.09
8.0.250.0040.00417.12
8.0.240.0000.00717.27
8.0.230.0000.00717.23
8.0.220.0000.00817.12
8.0.210.0030.00317.11
8.0.200.0030.00317.17
8.0.190.0030.00517.23
8.0.180.0030.00317.01
8.0.170.0000.00817.04
8.0.160.0040.00417.16
8.0.150.0040.00417.13
8.0.140.0000.00917.07
8.0.130.0030.00313.61
8.0.120.0000.00817.13
8.0.110.0040.00417.21
8.0.100.0000.00817.20
8.0.90.0040.00417.15
8.0.80.0130.00317.19
8.0.70.0040.00417.21
8.0.60.0000.00717.02
8.0.50.0020.00516.97
8.0.30.0110.01317.17
8.0.20.0140.00417.40
8.0.10.0000.00817.25
8.0.00.0090.00917.16
7.4.330.0000.00515.00
7.4.320.0030.00516.84
7.4.300.0050.00216.83
7.4.290.0030.00516.77
7.4.280.0000.00716.84
7.4.270.0070.00016.80
7.4.260.0070.00016.75
7.4.250.0030.00516.80
7.4.240.0030.00516.85
7.4.230.0000.00716.68
7.4.220.0130.01316.84
7.4.210.0060.01016.89
7.4.200.0000.00716.61
7.4.190.0030.00316.73
7.4.160.0030.01416.65
7.4.150.0040.01417.40
7.4.140.0050.01317.86
7.4.130.0100.00916.80
7.4.120.0100.01016.71
7.4.110.0100.01316.68
7.4.100.0060.01216.74
7.4.90.0130.00616.78
7.4.80.0150.00419.39
7.4.70.0100.01016.49
7.4.60.0070.01116.94
7.4.50.0060.00316.75
7.4.40.0030.01322.77
7.4.30.0030.01316.90
7.4.10.0000.01815.24
7.4.00.0080.00715.34
7.3.330.0050.00013.39
7.3.320.0000.00513.33
7.3.310.0080.00016.43
7.3.300.0030.00316.43
7.3.290.0070.01316.58
7.3.280.0080.00916.56
7.3.270.0120.00617.40
7.3.260.0040.01416.52
7.3.250.0090.00816.73
7.3.240.0100.00716.89
7.3.230.0060.01116.68
7.3.210.0120.00616.58
7.3.200.0130.00419.39
7.3.190.0100.00716.77
7.3.180.0000.00016.84
7.3.170.0130.01016.64
7.3.160.0090.01516.74
7.3.130.0150.00015.20
7.3.120.0070.00815.00
7.3.110.0070.01015.15
7.3.100.0030.01414.82
7.3.90.0030.01415.03
7.3.80.0060.00315.16
7.3.70.0100.00315.11
7.3.60.0000.01515.13
7.3.50.0040.00814.86
7.3.40.0040.01115.14
7.3.30.0100.00315.11
7.3.20.0070.00716.95
7.3.10.0060.00316.88
7.3.00.0040.01116.95
7.2.330.0070.01716.74
7.2.320.0130.01016.88
7.2.310.0160.00616.95
7.2.300.0100.00716.92
7.2.290.0060.01016.92
7.2.260.0070.01315.50
7.2.250.0120.00415.37
7.2.240.0090.00615.10
7.2.230.0000.01715.38
7.2.220.0070.01115.52
7.2.210.0100.00315.12
7.2.200.0030.00815.26
7.2.190.0060.00915.18
7.2.180.0030.00615.44
7.2.170.0070.00715.38
7.2.160.0070.00415.18
7.2.150.0100.00317.18
7.2.140.0050.00517.18
7.2.130.0110.00617.18
7.2.120.0000.01317.18
7.2.110.0030.00916.85
7.2.100.0060.00617.23
7.2.90.0070.01016.86
7.2.80.0070.01017.03
7.2.70.0060.00617.15
7.2.60.0030.01317.16
7.2.50.0060.00616.96
7.2.40.0060.01217.23
7.2.30.0150.00017.26
7.2.20.0060.00917.04
7.2.10.0060.00917.04
7.2.00.0050.01118.39
7.1.330.0000.01615.91
7.1.320.0090.00615.93
7.1.310.0030.01015.64
7.1.300.0120.00316.00
7.1.290.0040.00715.80
7.1.280.0030.01015.90
7.1.270.0030.01015.96
7.1.260.0060.00616.09
7.1.250.0050.00315.91
7.1.240.0040.01115.98
7.1.230.0040.00716.00
7.1.220.0000.01315.73
7.1.210.0030.00616.07
7.1.200.0060.01015.70
7.1.190.0030.01115.73
7.1.180.0000.01215.94
7.1.170.0120.00315.78
7.1.160.0070.00316.05
7.1.150.0080.00416.08
7.1.140.0060.00915.80
7.1.130.0000.01316.15
7.1.120.0070.00415.98
7.1.110.0030.01015.79
7.1.100.0080.00917.19
7.1.90.0070.01116.09
7.1.80.0070.01116.08
7.1.70.0040.00916.77
7.1.60.0030.01517.84
7.1.50.0050.01316.59
7.1.40.0090.00615.96
7.1.30.0060.00715.98
7.1.20.0070.00716.00
7.1.10.0070.00715.84
7.1.00.0060.04019.14
7.0.330.0000.01315.46
7.0.320.0040.01115.32
7.0.310.0060.00615.42
7.0.300.0040.01115.69
7.0.290.0030.01015.69
7.0.280.0060.00615.60
7.0.270.0040.00715.39
7.0.260.0070.00715.49
7.0.250.0110.00315.46
7.0.240.0090.00615.76
7.0.230.0070.01115.59
7.0.220.0080.00415.57
7.0.210.0030.01515.65
7.0.200.0050.00616.44
7.0.190.0030.01015.64
7.0.180.0040.00915.33
7.0.170.0070.00715.65
7.0.160.0060.00615.79
7.0.150.0030.00615.76
7.0.140.0050.04018.68
7.0.130.0090.00615.52
7.0.120.0040.00815.68
7.0.110.0070.00315.67
7.0.100.0040.01115.40
7.0.90.0040.00415.66
7.0.80.0060.00615.71
7.0.70.0120.00315.50
7.0.60.0070.02218.09
7.0.50.0070.03717.11
7.0.40.0070.04717.14
7.0.30.0170.04517.30
7.0.20.0100.02517.11
7.0.10.0200.04917.14
7.0.00.0020.04117.21
5.6.400.0090.00614.11
5.6.390.0080.00614.91
5.6.380.0030.01014.36
5.6.370.0060.00314.51
5.6.360.0030.01214.86
5.6.350.0040.00814.95
5.6.340.0070.00714.70
5.6.330.0070.00714.30
5.6.320.0070.00714.31
5.6.310.0070.01014.66
5.6.300.0070.00714.39
5.6.290.0060.00914.49
5.6.280.0030.03917.85
5.6.270.0120.00314.40
5.6.260.0000.01414.45
5.6.250.0060.00914.28
5.6.240.0040.00814.40
5.6.230.0060.00914.25
5.6.220.0070.01014.34
5.6.210.0050.03717.75
5.6.200.0100.04116.25
5.6.190.0100.02017.66
5.6.180.2030.02817.54
5.6.170.0130.02717.39
5.6.160.0070.04517.53
5.6.150.0030.04416.30
5.6.140.0020.04516.36
5.6.130.0070.04516.34
5.6.120.0090.03217.77
5.6.110.0060.03417.75
5.6.100.0050.04717.67
5.6.90.0040.04518.00
5.6.80.0020.02517.50
5.6.70.0180.03717.44
5.6.60.0000.00814.39
5.6.50.0030.01014.12
5.6.40.0120.00314.46
5.6.30.0070.00714.42
5.6.20.0030.01014.70
5.6.10.0080.00814.66
5.6.00.0090.00614.64
5.5.380.0000.01514.68
5.5.370.0100.00314.62
5.5.360.0070.01114.23
5.5.350.0080.04417.51
5.5.340.0080.02716.14
5.5.330.0000.05017.40
5.5.320.0210.03817.38
5.5.310.0180.02217.47
5.5.300.0010.02616.24
5.5.290.0070.02516.06
5.5.280.0090.04217.62
5.5.270.0090.04217.70
5.5.260.0090.04317.69
5.5.250.0070.03217.47
5.5.240.0070.02617.36
5.5.230.0030.00914.54
5.5.220.0040.00814.29
5.5.210.0080.00814.55
5.5.200.0040.00414.30
5.5.190.0000.01214.31
5.5.180.0080.00414.21
5.5.170.0060.00914.49
5.5.160.0030.01214.16
5.5.150.0060.00314.70
5.5.140.0070.00714.52
5.5.130.0030.00714.29
5.5.120.0080.00414.20
5.5.110.0000.01314.44
5.5.100.0070.00314.18
5.5.90.0060.00314.43
5.5.80.0060.00614.40
5.5.70.0060.01014.25
5.5.60.0100.00714.22
5.5.50.0000.01614.55
5.5.40.0060.00614.66
5.5.30.0090.00614.17
5.5.20.0070.01014.32
5.5.10.0080.00514.29
5.5.00.0070.00714.63
5.4.450.0310.03415.43
5.4.440.0270.02715.50
5.4.430.0310.02715.49
5.4.420.0070.03015.48
5.4.410.0230.03315.17
5.4.400.0400.00315.02
5.4.390.0480.00514.71
5.4.380.0180.02315.01
5.4.370.0150.02614.80
5.4.360.0130.02815.07
5.4.350.0120.03015.01
5.4.340.0150.02815.11
5.4.330.0070.00311.27
5.4.320.0050.02312.00
5.4.310.0040.02311.84
5.4.300.0040.02811.72
5.4.290.0130.04811.87
5.4.280.0080.02011.97
5.4.270.0050.02011.92
5.4.260.0100.02714.96
5.4.250.0090.02515.14
5.4.240.0030.03315.00
5.4.230.0070.04215.10
5.4.220.0080.02915.16
5.4.210.0050.03015.13
5.4.200.0060.04014.95
5.4.190.0050.03114.99
5.4.180.0040.04415.18
5.4.170.0030.03114.96
5.4.160.0100.02514.96
5.4.150.0050.03015.16
5.4.140.0070.03713.84
5.4.130.0030.03313.95
5.4.120.0080.03513.70
5.4.110.0050.03213.92
5.4.100.0030.02913.72
5.4.90.0110.03313.89
5.4.80.0110.02513.81
5.4.70.0050.03813.82
5.4.60.0070.02513.96
5.4.50.0080.02613.90
5.4.40.0050.02913.94
5.4.30.0080.02813.93
5.4.20.0020.03713.81
5.4.10.0080.03713.82
5.4.00.0070.03313.61
5.3.290.0020.02311.83
5.3.280.0050.03212.72
5.3.270.0060.03812.75
5.3.260.0080.02712.82
5.3.250.0110.02912.75
5.3.240.0080.03612.59
5.3.230.0090.02612.76
5.3.220.0100.03012.67
5.3.210.0090.03712.68
5.3.200.0030.02912.63
5.3.190.0020.04412.61
5.3.180.0050.02512.76
5.3.170.0020.03012.71
5.3.160.0050.03612.66
5.3.150.0130.02812.78
5.3.140.0020.03412.63
5.3.130.0100.02312.80
5.3.120.0050.03612.69
5.3.110.0030.03112.74
5.3.100.0100.03012.45
5.3.90.0070.02612.30
5.3.80.0070.03412.20
5.3.70.0050.03212.34
5.3.60.0020.03712.29
5.3.50.0050.02712.37
5.3.40.0020.03512.25
5.3.30.0100.03312.34
5.3.20.0050.03012.09
5.3.10.0040.04012.14
5.3.00.0040.03212.11
5.2.170.0130.03311.32
5.2.160.0100.03711.32
5.2.150.0030.04311.14
5.2.140.0000.05011.12
5.2.130.0030.04311.08
5.2.120.0100.04311.17
5.2.110.0000.04711.18
5.2.100.0100.04311.10
5.2.90.0030.04711.18
5.2.80.0200.03011.27
5.2.70.0130.05311.17
5.2.60.0130.05011.14
5.2.50.0030.06010.93
5.2.40.0070.04011.09
5.2.30.0100.03311.07
5.2.20.0130.04711.13
5.2.10.0000.04011.03
5.2.00.0030.04010.94
5.1.60.0000.03710.05
5.1.50.0030.0339.99
5.1.40.0030.03310.04
5.1.30.0030.04010.30
5.1.20.0030.03710.51
5.1.10.0100.03310.16
5.1.00.0070.03310.23
5.0.50.0000.0308.59
5.0.40.0030.0278.58
5.0.30.0030.0438.29
5.0.20.0000.0308.29
5.0.10.0030.0308.14
5.0.00.0000.0608.22
4.4.90.0070.0205.91
4.4.80.0030.0205.83
4.4.70.0000.0235.83
4.4.60.0000.0305.84
4.4.50.0000.0235.87
4.4.40.0000.0505.91
4.4.30.0000.0235.88
4.4.20.0030.0305.89
4.4.10.0000.0236.00
4.4.00.0000.0375.89
4.3.110.0070.0175.79
4.3.100.0000.0235.83
4.3.90.0070.0135.82
4.3.80.0000.0335.74
4.3.70.0030.0205.73
4.3.60.0030.0275.72
4.3.50.0000.0205.75
4.3.40.0070.0275.70
4.3.30.0030.0275.59
4.3.20.0000.0235.59
4.3.10.0000.0235.59
4.3.00.0100.0206.95

preferences:
44.98 ms | 404 KiB | 6 Q