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.0070.00718.55
8.3.50.0100.00921.27
8.3.40.0150.00019.04
8.3.30.0070.00719.04
8.3.20.0040.00420.23
8.3.10.0040.00422.11
8.3.00.0000.00822.43
8.2.180.0060.00916.63
8.2.170.0110.00422.96
8.2.160.0030.01019.44
8.2.150.0030.00524.18
8.2.140.0030.00524.66
8.2.130.0080.00026.16
8.2.120.0060.00319.61
8.2.110.0030.00622.19
8.2.100.0060.00619.76
8.2.90.0040.00419.29
8.2.80.0000.00918.03
8.2.70.0060.00317.74
8.2.60.0040.00418.03
8.2.50.0000.00918.07
8.2.40.0040.00419.94
8.2.30.0040.00418.18
8.2.20.0000.00717.91
8.2.10.0020.00518.01
8.2.00.0080.00018.00
8.1.280.0070.00725.92
8.1.270.0080.00022.23
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.00623.65
8.1.230.0090.00319.14
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0030.00617.60
8.1.190.0000.00817.53
8.1.180.0080.00018.88
8.1.170.0050.00318.75
8.1.160.0040.00422.22
8.1.150.0070.00018.82
8.1.140.0040.00417.70
8.1.130.0040.00417.81
8.1.120.0040.00417.67
8.1.110.0040.00417.58
8.1.100.0000.00717.66
8.1.90.0020.00517.65
8.1.80.0000.00717.67
8.1.70.0080.00017.63
8.1.60.0050.00317.73
8.1.50.0030.00517.63
8.1.40.0000.00817.73
8.1.30.0040.00417.85
8.1.20.0080.00017.80
8.1.10.0020.00517.64
8.1.00.0000.00917.72
8.0.300.0040.00418.77
8.0.290.0000.00717.18
8.0.280.0050.00218.46
8.0.270.0000.00817.33
8.0.260.0000.00717.07
8.0.250.0000.00817.24
8.0.240.0030.00517.26
8.0.230.0050.00317.21
8.0.220.0030.00317.04
8.0.210.0040.00417.15
8.0.200.0000.00817.09
8.0.190.0040.00417.12
8.0.180.0050.00317.16
8.0.170.0000.00817.16
8.0.160.0060.00316.98
8.0.150.0000.00717.05
8.0.140.0050.00317.06
8.0.130.0000.00613.58
8.0.120.0040.00416.93
8.0.110.0000.00817.14
8.0.100.0000.00717.10
8.0.90.0000.00717.04
8.0.80.0100.00717.15
8.0.70.0040.00417.04
8.0.60.0030.00516.94
8.0.50.0000.00817.02
8.0.30.0110.00817.36
8.0.20.0130.00717.40
8.0.10.0000.00817.25
8.0.00.0120.00917.05
7.4.330.0000.00515.00
7.4.320.0000.00716.68
7.4.300.0030.00316.80
7.4.290.0080.00016.86
7.4.280.0070.00016.81
7.4.270.0030.00316.83
7.4.260.0000.00716.64
7.4.250.0000.00716.73
7.4.240.0030.00516.84
7.4.230.0000.00716.70
7.4.220.0070.01716.83
7.4.210.0040.01016.76
7.4.200.0000.00716.86
7.4.190.0040.00416.85
7.4.160.0100.00716.78
7.4.150.0100.01417.40
7.4.140.0140.00317.86
7.4.130.0070.01316.70
7.4.120.0120.01116.68
7.4.110.0100.00716.72
7.4.100.0140.00316.60
7.4.90.0070.01116.68
7.4.80.0110.00719.39
7.4.70.0100.01016.74
7.4.60.0100.00716.81
7.4.50.0060.00316.52
7.4.40.0060.01022.77
7.4.30.0090.00616.63
7.4.00.0070.01015.04
7.3.330.0020.00313.39
7.3.320.0000.00513.40
7.3.310.0040.00416.52
7.3.300.0030.00316.52
7.3.290.0070.00716.58
7.3.280.0120.00816.58
7.3.270.0110.00617.40
7.3.260.0090.00916.54
7.3.250.0070.01516.57
7.3.240.0130.01016.83
7.3.230.0040.01416.79
7.3.210.0170.00316.81
7.3.200.0120.00319.39
7.3.190.0090.00916.51
7.3.180.0100.01016.78
7.3.170.0030.01716.55
7.3.160.0110.00616.76
7.3.120.0090.00914.87
7.2.330.0160.00316.85
7.2.320.0170.00717.01
7.2.310.0130.01016.93
7.2.300.0070.01416.92
7.2.290.0140.00316.95
7.2.110.0100.00016.60
7.2.100.0070.00316.59
7.2.90.0050.00516.96
7.2.80.0030.01016.65
7.2.70.0040.00717.23
7.2.60.0090.00417.11
7.2.50.0120.00317.24
7.2.40.0040.01117.14
7.2.30.0040.00717.20
7.2.20.0000.00817.16
7.2.10.0090.00317.02
7.2.00.0050.00918.33
7.1.230.0060.00616.06
7.1.220.0070.00015.80
7.1.210.0080.00416.13
7.1.200.0050.00716.16
7.1.190.0070.00715.88
7.1.180.0000.00915.99
7.1.170.0000.00816.05
7.1.160.0030.00615.94
7.1.150.0030.01016.02
7.1.140.0070.00716.01
7.1.130.0060.00615.77
7.1.120.0090.00315.74
7.1.110.0040.00416.19
7.1.100.0030.01017.29
7.1.90.0090.00615.96
7.1.80.0060.00315.82
7.1.70.0050.00516.65
7.1.60.0050.01318.00
7.1.50.0050.01416.48
7.1.40.0100.00016.03
7.1.30.0100.00316.07
7.1.20.0070.00716.00
7.1.10.0070.00315.87
7.1.00.0120.03319.12
7.0.310.0060.00315.63
7.0.300.0000.00715.55
7.0.290.0100.00015.60
7.0.280.0050.00315.72
7.0.270.0040.00415.16
7.0.260.0060.00615.74
7.0.250.0060.00615.65
7.0.240.0030.00715.71
7.0.230.0110.00315.37
7.0.220.0000.00815.61
7.0.210.0040.00815.46
7.0.200.0040.00516.35
7.0.190.0030.01015.41
7.0.180.0000.00915.50
7.0.170.0030.00615.75
7.0.160.0040.00715.46
7.0.150.0000.01015.52
7.0.140.0020.04018.88
7.0.130.0090.00315.40
7.0.120.0090.00315.63
7.0.110.0040.01115.63
7.0.100.0100.02917.82
7.0.90.0080.02317.70
7.0.80.0050.02517.78
7.0.70.0170.02717.88
7.0.60.0050.02418.14
7.0.50.0090.04018.32
7.0.40.0080.03717.13
7.0.30.0100.04017.23
7.0.20.0070.04217.09
7.0.10.0110.02317.12
7.0.00.0100.04317.03
5.6.380.0080.00314.69
5.6.370.0000.00914.86
5.6.360.0060.00314.88
5.6.350.0050.00514.44
5.6.340.0030.01014.44
5.6.330.0030.00914.53
5.6.320.0070.00314.61
5.6.310.0110.00014.48
5.6.300.0030.00714.78
5.6.290.0060.00614.36
5.6.280.0020.04117.90
5.6.270.0030.00614.32
5.6.260.0080.00014.39
5.6.250.0080.03317.69
5.6.240.0080.03817.60
5.6.230.0080.04317.50
5.6.220.0020.02417.54
5.6.210.0080.04017.55
5.6.200.0110.03817.80
5.6.190.0110.03917.81
5.6.180.0050.03317.74
5.6.170.0120.04217.90
5.6.160.0080.02517.83
5.6.150.0060.02117.74
5.6.140.0090.04017.92
5.6.130.0100.04117.68
5.6.120.0030.03317.85
5.6.110.0080.04117.75
5.6.100.0050.03517.94
5.6.90.0110.04017.79
5.6.80.0120.03917.39
5.6.70.0050.04417.39
5.6.60.0070.03017.27
5.6.50.0050.04517.50
5.6.40.0050.04017.59
5.6.30.0100.03017.33
5.6.20.0050.02417.54
5.6.10.0070.04017.44
5.6.00.0020.02717.29
5.5.380.0050.04215.97
5.5.370.0060.04315.99
5.5.360.0070.03416.01
5.5.350.0060.05015.80
5.5.340.0080.02216.25
5.5.330.0080.04115.98
5.5.320.0070.03816.26
5.5.310.0050.02316.08
5.5.300.0050.04316.03
5.5.290.0070.03716.13
5.5.280.0040.02916.07
5.5.270.0070.03416.21
5.5.260.0030.02316.12
5.5.250.0020.04015.91
5.5.240.0050.03515.79
5.5.230.0040.03715.70
5.5.220.0030.03115.73
5.5.210.0070.03415.83
5.5.200.0100.03815.67
5.5.190.0050.04015.84
5.5.180.0070.03715.80
5.5.170.0100.00314.44
5.5.160.0070.02315.72
5.5.150.0050.02615.84
5.5.140.0060.04215.65
5.5.130.0050.02715.68
5.5.120.0060.03615.75
5.5.110.0050.03215.76
5.5.100.0060.02415.72
5.5.90.0100.01715.67
5.5.80.0070.04015.48
5.5.70.0030.02115.68
5.5.60.0080.03015.70
5.5.50.0030.04215.74
5.5.40.0060.04015.61
5.5.30.0050.04415.49
5.5.20.0070.03515.58
5.5.10.0020.04615.56
5.5.00.0070.04215.76
5.4.450.0030.02615.21
5.4.440.0030.03215.46
5.4.430.0050.02515.44
5.4.420.0070.04315.38
5.4.410.0100.03615.42
5.4.400.0080.03815.07
5.4.390.0000.04415.26
5.4.380.0080.03714.97
5.4.370.0090.03815.22
5.4.360.0070.03715.13
5.4.350.0050.03715.11
5.4.340.0070.03715.19
5.4.330.0060.00611.32
5.4.320.0050.04015.11
5.4.310.0030.03815.25
5.4.300.0070.04015.10
5.4.290.0040.04014.98
5.4.280.0050.03315.26
5.4.270.0000.03915.15
5.4.260.0070.03715.32
5.4.250.0070.02115.03
5.4.240.0020.02615.23
5.4.230.0050.02015.08
5.4.220.0030.04315.06
5.4.210.0070.03515.20
5.4.200.0030.02115.05
5.4.190.0020.02915.06
5.4.180.0080.04015.03
5.4.170.0070.02515.11
5.4.160.0050.04015.04
5.4.150.0080.03115.24
5.4.140.0030.03013.95
5.4.130.0000.02813.79
5.4.120.0020.02913.84
5.4.110.0050.02813.82
5.4.100.0070.01813.89
5.4.90.0000.03713.89
5.4.80.0030.03313.91
5.4.70.0060.03513.86
5.4.60.0050.02213.88
5.4.50.0020.03213.89
5.4.40.0070.02013.82
5.4.30.0080.02613.70
5.4.20.0050.03113.82
5.4.10.0030.01813.67
5.4.00.0060.02813.52
5.3.290.0110.03212.79
5.3.280.0050.03612.71
5.3.270.0020.04712.71
5.3.260.0060.03812.77
5.3.250.0090.03312.69
5.3.240.0080.03312.63
5.3.230.0060.03212.71
5.3.220.0080.03612.65
5.3.210.0050.02612.61
5.3.200.0090.02012.49
5.3.190.0030.04412.58
5.3.180.0040.03912.63
5.3.170.0040.03012.73
5.3.160.0040.03712.53
5.3.150.0150.01712.78
5.3.140.0070.02312.72
5.3.130.0050.02112.71
5.3.120.0080.04012.71
5.3.110.0020.05412.70
5.3.100.0060.01812.43
5.3.90.0040.01912.37
5.3.80.0070.03612.16
5.3.70.0060.03112.44
5.3.60.0090.03112.24
5.3.50.0050.03212.23
5.3.40.0050.02612.13
5.3.30.0060.02012.29
5.3.20.0070.02412.15
5.3.10.0110.02012.01
5.3.00.0050.03912.02
5.2.170.0040.03110.97
5.2.160.0040.02410.88
5.2.150.0040.02710.94
5.2.140.0110.01910.99
5.2.130.0050.02711.00
5.2.120.0020.02910.85
5.2.110.0050.01810.97
5.2.100.0070.02110.86
5.2.90.0040.01910.99
5.2.80.0090.02310.93
5.2.70.0030.02311.04
5.2.60.0080.01710.87
5.2.50.0020.03610.93
5.2.40.0020.02610.99
5.2.30.0050.02810.96
5.2.20.0040.01910.78
5.2.10.0060.02810.92
5.2.00.0050.01810.74
5.1.60.0000.03010.66
5.1.50.0030.01310.66
5.1.40.0050.02510.66
5.1.30.0080.01710.66
5.1.20.0030.02710.66
5.1.10.0010.02010.66
5.1.00.0030.03010.66
5.0.50.0030.02510.66
5.0.40.0060.01710.66
5.0.30.0020.02810.66
5.0.20.0040.02310.66
5.0.10.0050.02310.66
5.0.00.0030.03510.66
4.4.90.0010.01110.66
4.4.80.0000.01810.66
4.4.70.0010.01310.66
4.4.60.0020.01910.66
4.4.50.0000.02010.66
4.4.40.0030.01810.66
4.4.30.0030.01810.66
4.4.20.0010.01110.66
4.4.10.0060.01210.66
4.4.00.0010.03110.66
4.3.110.0030.02010.66
4.3.100.0020.01210.66
4.3.90.0010.01110.66
4.3.80.0040.02610.66
4.3.70.0060.00710.66
4.3.60.0000.01710.66
4.3.50.0020.01310.66
4.3.40.0000.02510.66
4.3.30.0010.01310.66
4.3.20.0030.00810.66
4.3.10.0000.01210.66
4.3.00.0030.01810.66

preferences:
44.61 ms | 401 KiB | 5 Q