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/public'; 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.0090.01218.31
8.3.50.0110.00922.17
8.3.40.0120.00319.17
8.3.30.0040.01119.01
8.3.20.0080.00020.39
8.3.10.0080.00021.95
8.3.00.0040.00422.55
8.2.180.0030.01516.63
8.2.170.0110.00422.96
8.2.160.0110.00719.21
8.2.150.0070.00324.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0000.00819.73
8.2.110.0000.01022.03
8.2.100.0100.00017.96
8.2.90.0000.00818.09
8.2.80.0040.00417.97
8.2.70.0040.00417.75
8.2.60.0000.00818.04
8.2.50.0040.00418.07
8.2.40.0050.00318.22
8.2.30.0040.00418.25
8.2.20.0000.00717.85
8.2.10.0080.00017.96
8.2.00.0000.00717.99
8.1.280.0060.00925.92
8.1.270.0040.00422.18
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00322.47
8.1.230.0040.00721.16
8.1.220.0000.00817.78
8.1.210.0080.00019.04
8.1.200.0070.00317.73
8.1.190.0050.00317.55
8.1.180.0050.00318.96
8.1.170.0050.00318.84
8.1.160.0030.00622.17
8.1.150.0030.00618.83
8.1.140.0000.00817.57
8.1.130.0000.00717.95
8.1.120.0030.00417.70
8.1.110.0000.00817.63
8.1.100.0000.00717.54
8.1.90.0040.00417.64
8.1.80.0000.00717.63
8.1.70.0050.00317.60
8.1.60.0090.00017.79
8.1.50.0000.00817.62
8.1.40.0000.00717.59
8.1.30.0030.00617.78
8.1.20.0040.00417.76
8.1.10.0000.00817.78
8.1.00.0000.01117.67
8.0.300.0040.00420.15
8.0.290.0070.00017.18
8.0.280.0030.00318.50
8.0.270.0040.00417.24
8.0.260.0060.00017.06
8.0.250.0000.00717.27
8.0.240.0040.00417.24
8.0.230.0040.00417.18
8.0.220.0000.00717.14
8.0.210.0000.00817.15
8.0.200.0000.00717.18
8.0.190.0040.00417.14
8.0.180.0000.00717.18
8.0.170.0080.00017.16
8.0.160.0080.00017.12
8.0.150.0080.00017.16
8.0.140.0040.00417.07
8.0.130.0000.00513.61
8.0.120.0000.00817.10
8.0.110.0040.00416.96
8.0.100.0040.00417.09
8.0.90.0000.00817.13
8.0.80.0110.00717.14
8.0.70.0000.00717.18
8.0.60.0070.00017.16
8.0.50.0040.00417.02
8.0.30.0140.00517.39
8.0.20.0110.00817.40
8.0.10.0070.00017.21
8.0.00.0100.00716.93
7.4.330.0030.00315.00
7.4.320.0000.00816.91
7.4.300.0000.00716.86
7.4.290.0030.00316.71
7.4.280.0000.00716.76
7.4.270.0000.00716.76
7.4.260.0050.00316.72
7.4.250.0040.00416.87
7.4.240.0010.00616.82
7.4.230.0030.00316.89
7.4.220.0060.01216.68
7.4.210.0090.00616.81
7.4.200.0000.00716.68
7.4.190.0070.00016.73
7.4.160.0110.00616.89
7.4.150.0070.01017.40
7.4.140.0080.01117.86
7.4.130.0130.00916.76
7.4.120.0130.01016.64
7.4.110.0140.00716.77
7.4.100.0090.00916.88
7.4.90.0090.00916.71
7.4.80.0160.00319.39
7.4.70.0170.00516.79
7.4.60.0100.00716.77
7.4.50.0000.00716.87
7.4.40.0030.01422.77
7.4.30.0060.01616.68
7.4.00.0080.00814.98
7.3.330.0000.00513.42
7.3.320.0020.00213.42
7.3.310.0090.00016.56
7.3.300.0030.00316.43
7.3.290.0110.00316.50
7.3.280.0090.00816.59
7.3.270.0140.00317.40
7.3.260.0100.01016.62
7.3.250.0070.01016.55
7.3.240.0120.00616.63
7.3.230.0100.01016.94
7.3.210.0040.01416.80
7.3.200.0090.00919.39
7.3.190.0040.01516.54
7.3.180.0060.01016.55
7.3.170.0060.01016.63
7.3.160.0130.01016.84
7.3.120.0070.00715.18
7.2.330.0120.00917.04
7.2.320.0120.00916.72
7.2.310.0120.00616.97
7.2.300.0070.01016.96
7.2.290.0070.01016.98
7.2.60.0030.01017.16
7.2.00.0030.00919.88
7.1.200.0060.00616.00
7.1.100.0060.00618.38
7.1.70.0000.00717.30
7.1.60.0070.01419.82
7.1.50.0140.01117.27
7.1.00.0030.07722.36
7.0.200.0040.00416.93
7.0.140.0070.07321.93
7.0.60.0100.06020.19
7.0.50.0100.03718.23
7.0.40.0100.08320.68
7.0.30.0100.05720.43
7.0.20.0230.06720.37
7.0.10.0170.06720.35
7.0.00.0070.09020.50
5.6.280.0030.07021.13
5.6.210.0030.07320.53
5.6.200.0070.08318.16
5.6.190.0070.04020.63
5.6.180.2930.04320.67
5.6.170.0330.07320.56
5.6.160.0070.08720.44
5.6.150.0000.05718.14
5.6.140.0130.07718.14
5.6.130.0100.06018.16
5.6.120.0070.04721.06
5.6.110.0000.04321.02
5.6.100.0070.07021.01
5.6.90.0030.08321.00
5.6.80.0070.03720.40
5.6.70.4030.03720.38
5.5.350.0370.07020.35
5.5.340.0070.08317.94
5.5.330.0070.07320.29
5.5.320.3630.04020.19
5.5.310.0300.07020.41
5.5.300.0030.04317.98
5.5.290.0070.07318.05
5.5.280.0070.08320.63
5.5.270.0000.05320.82
5.5.260.0100.06720.70
5.5.250.0100.07720.73
5.5.240.0270.03720.29
5.4.450.0500.06719.70
5.4.440.0700.04719.39
5.4.430.0230.06019.16
5.4.420.0200.05319.63
5.4.410.0530.04319.48
5.4.400.0870.00018.83
5.4.390.0870.00018.80
5.4.380.0270.05018.75
5.4.370.0330.05018.52
5.4.360.0470.04018.79
5.4.350.0330.05318.57
5.4.340.0330.05718.49
5.4.320.0100.03412.53
5.4.310.0030.04012.53
5.4.300.0080.05112.53
5.4.290.0070.04312.53
5.4.280.0090.03912.42
5.4.270.0110.04512.42
5.4.260.0030.06719.06
5.4.250.0130.04718.82
5.4.240.0030.05718.93
5.4.230.0070.05318.64
5.4.220.0070.05718.99
5.4.210.0130.07018.74
5.4.200.0130.05318.78
5.4.190.0030.07719.00
5.4.180.0200.05318.89
5.4.170.0130.04718.77
5.4.160.0100.06019.08
5.4.150.0130.04718.82
5.4.140.0000.05716.43
5.4.130.0000.05716.56
5.4.120.0070.05016.38
5.4.110.0130.05016.61
5.4.100.0170.05716.61
5.4.90.0070.05716.32
5.4.80.0070.06716.55
5.4.70.0200.03716.42
5.4.60.0070.06016.53
5.4.50.0130.04316.42
5.4.40.0100.04716.57
5.4.30.0070.05316.63
5.4.20.0070.07316.59
5.4.10.0170.06716.59
5.4.00.0070.05015.82
5.3.290.0020.04412.80
5.3.280.0030.05314.55
5.3.270.0100.05014.73
5.3.260.0100.05314.81
5.3.250.0070.05014.79
5.3.240.0130.04714.61
5.3.230.0100.05314.64
5.3.220.0070.07314.52
5.3.210.0070.06314.76
5.3.200.0070.05014.73
5.3.190.0070.07014.68
5.3.180.0100.07314.76
5.3.170.0070.06014.60
5.3.160.0070.05014.67
5.3.150.0070.05714.66
5.3.140.0070.05314.75
5.3.130.0100.05314.55
5.3.120.0030.06014.74
5.3.110.0070.08014.65
5.3.100.0070.05014.04
5.3.90.0070.06314.19
5.3.80.0030.06014.12
5.3.70.0070.05714.07
5.3.60.0070.05314.11
5.3.50.0130.04714.16
5.3.40.0100.04714.06
5.3.30.0000.05314.03
5.3.20.0130.05013.71
5.3.10.0100.04713.51
5.3.00.0100.07013.67
5.2.170.0030.04711.14
5.2.160.0130.04711.05
5.2.150.0070.04011.21
5.2.140.0100.04011.22
5.2.130.0030.04311.10
5.2.120.0030.04711.10
5.2.110.0100.05011.00
5.2.100.0070.04011.09
5.2.90.0070.04011.09
5.2.80.0100.04311.16
5.2.70.0000.06011.15
5.2.60.0070.04011.04
5.2.50.0030.06011.02
5.2.40.0070.03711.07
5.2.30.0100.04310.93
5.2.20.0100.03710.97
5.2.10.0000.04710.84
5.2.00.0100.03310.72
5.1.60.0070.03010.05
5.1.50.0070.04310.00
5.1.40.0070.03710.18
5.1.30.0100.03310.41
5.1.20.0000.04010.36
5.1.10.0030.05010.27
5.1.00.0000.04010.16
5.0.50.0070.0408.49
5.0.40.0100.0338.50
5.0.30.0000.0478.46
5.0.20.0070.0238.26
5.0.10.0100.0308.10
5.0.00.0100.0378.11
4.4.90.0030.0205.87
4.4.80.0000.0235.81
4.4.70.0030.0205.89
4.4.60.0070.0175.85
4.4.50.0000.0235.86
4.4.40.0030.0335.81
4.4.30.0070.0205.86
4.4.20.0070.0305.96
4.4.10.0070.0275.98
4.4.00.0000.0435.87
4.3.110.0000.0275.70
4.3.100.0070.0175.69
4.3.90.0070.0235.77
4.3.80.0030.0375.77
4.3.70.0030.0205.76
4.3.60.0000.0335.76
4.3.50.0000.0235.77
4.3.40.0070.0275.69
4.3.30.0030.0305.61
4.3.20.0030.0205.61
4.3.10.0030.0205.61
4.3.00.0000.0337.57

preferences:
48.09 ms | 401 KiB | 5 Q