3v4l.org

run code in 300+ PHP versions simultaneously
<?php function make_absolute_path($a,$b){if((!$c=parse_url($a))||(!$d=parse_url($b))){return FALSE;}if(empty($c['host'])&&!empty($c['path'])&&substr($c['path'],0,2)==='//'){$e=explode('/',ltrim($c['path'],'/'));$c['host']=array_shift($e);$c['path']='/'.implode('/',$e);}if(empty($d['host'])&&!empty($d['path'])&&substr($d['path'],0,2)==='//'){$e=explode('/',ltrim($d['path'],'/'));$d['host']=array_shift($e);$d['path']='/'.implode('/',$e);}if(!empty($d['host'])){return $b;}if(empty($c['host'])){return FALSE;}if(empty($c['path'])){$c['path']='/';}if(empty($c['scheme'])){$c['scheme']='http';}$f=$c['scheme'].'://';if(!empty($c['user'])){$f.=$c['user'];if(!empty($c['pass'])){$f.=":{$c['pass']}";}$f.='@';}$f.=!empty($c['port'])?"{$c['host']}:{$c['port']}":$c['host'];if($b[0]==='/'){$f.=$b;}else if($b[0]==='?'){$f.=$c['path'].$b;}else{$g=rtrim(substr($c['path'],-1)==='/'?trim($c['path']):str_replace('\\','/',dirname(trim($c['path']))),'/');foreach(explode('/',$b)as $h){switch($h){case '':case '.':break;case '..':$g=rtrim(str_replace('\\','/',dirname($g)),'/');break;default:$g.="/$h";break;}}$f.=$g;}return $f;}$i=array(1=>array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'/photos/photo.jpg','expect'=>'http://www.xxx.com/photos/photo.jpg'),array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'/photos/photo.jpg','expect'=>'http://www.xxx.com/photos/photo.jpg'),array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'photos/photo.jpg','expect'=>'http://www.xxx.com/dir/photos/photo.jpg'),array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'./photos/photo.jpg','expect'=>'http://www.xxx.com/dir/photos/photo.jpg'),array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'../photos/photo.jpg','expect'=>'http://www.xxx.com/photos/photo.jpg'),array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'//www.yyy.com/photos/photo.jpg','expect'=>'//www.yyy.com/photos/photo.jpg'),array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'?query=something','expect'=>'http://www.xxx.com/dir/index.php?query=something'),array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'?query=something#fragment','expect'=>'http://www.xxx.com/dir/index.php?query=something#fragment'),array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'/photos/photo.jpg#fragment','expect'=>'http://www.xxx.com/photos/photo.jpg#fragment'),array('arg1'=>'http://www.xxx.com/dir/index.php','arg2'=>'../../photos/photo.jpg','expect'=>'http://www.xxx.com/photos/photo.jpg'),array('arg1'=>'http://www.xxx.com/dir/sub1/sub2/index.php','arg2'=>'../../photo/photo.jpg','expect'=>'http://www.xxx.com/dir/photo/photo.jpg'),array('arg1'=>'//www.xxx.com/dir/index.php','arg2'=>'test?query=something','expect'=>'http://www.xxx.com/dir/test?query=something'));foreach($i as $j=>$k){$f=make_absolute_path($k['arg1'],$k['arg2']);echo" Test #$j (".($f===$k['expect']?'PASS':'FAIL').") Arg 1: {$k['arg1']} Arg 2: {$k['arg2']} Expect: {$k['expect']} Result: $f ";}

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.0000.01416.63
8.3.50.0080.00718.33
8.3.40.0090.00618.83
8.3.30.0160.00318.76
8.3.20.0090.00018.63
8.3.10.0050.00520.40
8.3.00.0080.00019.38
8.2.180.0120.00416.50
8.2.170.0160.00322.96
8.2.160.0100.00620.61
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0050.00326.16
8.2.120.0030.00620.63
8.2.110.0040.00721.10
8.2.100.0070.00417.72
8.2.90.0000.00921.06
8.2.80.0000.00919.46
8.2.70.0040.00417.63
8.2.60.0060.00318.16
8.2.50.0070.00418.07
8.2.40.0040.00418.28
8.2.30.0040.00418.05
8.2.20.0040.00417.75
8.2.10.0000.00717.70
8.2.00.0000.00817.70
8.1.280.0110.00425.92
8.1.270.0080.00023.99
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00322.59
8.1.230.0170.00420.82
8.1.220.0060.00317.74
8.1.210.0080.00318.93
8.1.200.0070.00417.48
8.1.190.0080.00017.75
8.1.180.0060.00318.10
8.1.170.0040.00418.90
8.1.160.0070.00018.96
8.1.150.0090.00018.72
8.1.140.0040.00417.44
8.1.130.0000.00717.88
8.1.120.0000.00817.42
8.1.110.0000.00817.56
8.1.100.0000.00717.52
8.1.90.0080.00017.57
8.1.80.0000.00717.42
8.1.70.0070.00017.44
8.1.60.0080.00017.66
8.1.50.0040.00417.48
8.1.40.0000.00817.56
8.1.30.0050.00317.65
8.1.20.0070.00317.79
8.1.10.0000.00917.55
8.1.00.0000.00817.50
8.0.300.0050.00319.78
8.0.290.0000.00816.88
8.0.280.0070.00018.52
8.0.270.0040.00417.31
8.0.260.0030.00316.86
8.0.250.0000.00717.04
8.0.240.0040.00416.89
8.0.230.0070.00017.05
8.0.220.0070.00017.00
8.0.210.0000.00716.93
8.0.200.0030.00316.91
8.0.190.0030.00617.03
8.0.180.0080.00016.93
8.0.170.0090.00016.93
8.0.160.0040.00417.02
8.0.150.0040.00416.82
8.0.140.0050.00316.83
8.0.130.0050.00013.46
8.0.120.0020.00515.07
8.0.110.0050.00215.11
8.0.100.0030.00315.20
8.0.90.0030.00415.16
8.0.80.0040.00915.15
8.0.70.0030.00415.12
8.0.60.0040.00315.05
8.0.50.0030.00315.12
8.0.30.0040.00815.36
8.0.20.0090.00916.02
8.0.10.0020.00515.28
8.0.00.0110.00615.82
7.4.330.0000.00513.06
7.4.320.0030.00316.48
7.4.300.0030.00316.68
7.4.290.0080.00016.57
7.4.280.0000.00816.64
7.4.270.0070.00016.61
7.4.260.0000.00513.28
7.4.250.0020.00515.08
7.4.240.0000.00714.95
7.4.230.0020.00514.85
7.4.220.0090.00315.04
7.4.210.0030.01014.95
7.4.200.0000.00615.01
7.4.190.0030.00315.10
7.4.180.0050.00013.33
7.4.160.0060.00515.03
7.4.150.0040.00914.98
7.4.140.0100.00214.79
7.4.130.0070.00515.02
7.4.120.0060.00514.96
7.4.110.0100.00314.87
7.4.100.0090.00614.99
7.4.90.0060.00614.85
7.4.80.0050.00916.31
7.4.70.0050.01014.85
7.4.60.0050.00614.90
7.4.50.0030.00314.84
7.4.40.0030.00814.82
7.4.30.0110.00014.98
7.4.20.0030.00313.30
7.4.10.0040.00313.27
7.4.00.0050.00614.18
7.3.330.0000.00713.36
7.3.320.0050.00013.22
7.3.310.0040.00314.84
7.3.300.0040.00214.97
7.3.290.0070.00415.64
7.3.280.0060.00815.35
7.3.270.0030.00815.03
7.3.260.0090.00314.93
7.3.250.0060.00715.50
7.3.240.0090.00314.90
7.3.230.0090.00414.96
7.3.220.0050.00313.43
7.3.210.0100.00414.97
7.3.200.0040.00914.89
7.3.190.0040.00714.98
7.3.180.0110.00014.92
7.3.170.0080.00314.99
7.3.160.0070.00414.80
7.3.150.0000.00613.36
7.3.140.0080.00013.31
7.3.130.0030.00313.27
7.3.120.0050.00713.86
7.3.110.0050.00013.31
7.3.100.0050.00213.36
7.3.90.0000.00613.48
7.3.80.0050.00013.44
7.3.70.0030.00313.48
7.3.60.0060.00013.41
7.3.50.0030.00313.63
7.3.40.0030.00313.38
7.3.30.0000.00513.56
7.3.20.0060.00015.23
7.3.10.0000.00515.08
7.3.00.0000.00615.22
7.2.340.0130.00013.31
7.2.330.0110.00614.89
7.2.320.0110.00815.06
7.2.310.0080.01015.00
7.2.300.0090.00615.03
7.2.290.0110.00715.07
7.2.280.0130.00013.30
7.2.270.0110.00313.53
7.2.260.0130.00013.31
7.2.250.0130.00013.45
7.2.240.0040.01113.41
7.2.230.0110.00313.48
7.2.220.0100.00313.27
7.2.210.0090.00313.37
7.2.200.0150.00013.50
7.2.190.0130.00013.59
7.2.180.0130.00013.43
7.2.170.0060.00613.63
7.2.160.0100.00313.50
7.2.150.0080.00515.16
7.2.140.0080.00415.41
7.2.130.0130.00015.35
7.2.120.0130.00015.30
7.2.110.0130.00015.32
7.2.100.0130.00015.27
7.2.90.0000.01515.39
7.2.80.0110.00215.23
7.2.70.0100.00315.25
7.2.60.0020.01216.26
7.2.50.0140.00015.38
7.2.40.0150.00015.23
7.2.30.0080.00615.36
7.2.20.0090.00515.35
7.2.10.0070.00715.33
7.2.00.0100.00315.49
7.1.330.0110.00014.39
7.1.320.0120.00014.41
7.1.310.0060.00614.35
7.1.300.0110.00014.29
7.1.290.0040.00814.40
7.1.280.0120.00014.45
7.1.270.0090.00314.25
7.1.260.0110.00014.12
7.1.250.0080.00514.18
7.1.240.0090.00214.15
7.1.230.0080.00414.18
7.1.220.0060.00614.41
7.1.210.0120.00314.25
7.1.200.0050.00815.06
7.1.190.0100.00214.42
7.1.180.0120.00014.41
7.1.170.0040.00814.28
7.1.160.0080.00414.34
7.1.150.0120.00014.15
7.1.140.0060.00614.33
7.1.130.0120.00014.16
7.1.120.0080.00414.20
7.1.110.0130.00014.31
7.1.100.0080.00516.33
7.1.90.0080.00414.37
7.1.80.0120.00014.27
7.1.70.0080.00815.58
7.1.60.0100.00716.85
7.1.50.0080.00715.49
7.1.40.0080.00414.26
7.1.30.0090.00314.23
7.1.20.0060.00614.18
7.1.10.0100.00314.23
7.1.00.0030.02318.29
7.0.330.0090.00314.31
7.0.320.0040.00814.25
7.0.310.0090.00314.21
7.0.300.0110.00014.23
7.0.290.0120.00014.29
7.0.280.0090.00314.05
7.0.270.0080.00314.07
7.0.260.0040.00814.02
7.0.250.0120.00014.27
7.0.240.0080.00314.23
7.0.230.0060.00614.36
7.0.220.0030.00914.33
7.0.210.0090.00314.20
7.0.200.0150.00614.61
7.0.190.0100.00214.27
7.0.180.0120.00014.27
7.0.170.0110.00014.11
7.0.160.0110.00014.26
7.0.150.0180.00014.21
7.0.140.0060.03918.12
7.0.130.0100.00614.15
7.0.120.0030.04018.25
7.0.110.0100.00314.21
7.0.100.0060.00614.21
7.0.90.0110.00014.13
7.0.80.0120.00014.18
7.0.70.0090.00314.22
7.0.60.0170.03417.18
7.0.50.0020.02715.96
7.0.40.0070.02217.16
7.0.30.0210.04017.14
7.0.20.0190.02817.15
7.0.10.0080.04417.09
7.0.00.0090.02817.15
5.6.400.0040.00812.71
5.6.390.0120.00012.74
5.6.380.0040.00813.00
5.6.370.0130.00012.89
5.6.360.0060.00612.69
5.6.350.0080.00312.69
5.6.340.0080.00412.71
5.6.330.0120.00012.84
5.6.320.0070.00412.93
5.6.310.0120.00012.85
5.6.300.0070.00512.73
5.6.290.0090.00312.83
5.6.280.0050.03816.83
5.6.270.0080.00412.67
5.6.260.0120.00012.89
5.6.250.0120.00012.84
5.6.240.0040.00712.76
5.6.230.0070.00413.00
5.6.220.0080.00412.97
5.6.210.0120.02816.84
5.6.200.0090.04015.72
5.6.190.0040.04716.84
5.6.180.0160.02516.87
5.6.170.0220.03216.83
5.6.160.0090.02216.88
5.6.150.0110.02815.63
5.6.140.0100.02015.53
5.6.130.0090.04015.57
5.6.120.0060.02216.96
5.6.110.0110.03817.00
5.6.100.0100.04017.06
5.6.90.0060.04616.97
5.6.80.0090.03716.65
5.6.70.0070.00412.96
5.6.60.0050.00512.99
5.6.50.0000.01012.80
5.6.40.0050.00512.92
5.6.30.0050.00512.80
5.6.20.0110.00012.84
5.6.10.0110.00012.73
5.6.00.0060.00612.75
5.5.380.0040.00813.11
5.5.370.0080.00313.03
5.5.360.0110.00012.82
5.5.350.0020.02216.56
5.5.340.0090.02315.40
5.5.330.0120.03516.52
5.5.320.0800.03316.67
5.5.310.0120.03816.67
5.5.300.0030.04615.50
5.5.290.0050.02315.40
5.5.280.0070.02316.84
5.5.270.0060.04316.92
5.5.260.0050.04716.88
5.5.250.0090.01816.69
5.5.240.0090.03716.62
5.5.230.0080.00313.09
5.5.220.0070.00412.69
5.5.210.0070.00312.83
5.5.200.0070.00312.78
5.5.190.0090.00212.76
5.5.180.0070.00412.75
5.5.170.0100.00212.76
5.5.160.0100.00312.78
5.5.150.0100.00012.71
5.5.140.0050.00512.79
5.5.130.0070.00412.83
5.5.120.0110.00012.66
5.5.110.0060.00612.80
5.5.100.0040.00713.11
5.5.90.0060.00612.81
5.5.80.0120.00013.07
5.5.70.0060.00612.93
5.5.60.0050.00713.05
5.5.50.0070.00312.91
5.5.40.0060.00612.96
5.5.30.0080.00312.89
5.5.20.0090.00213.04
5.5.10.0000.01112.98
5.5.00.0110.00012.82
5.4.450.0270.02519.00
5.4.440.0220.02019.00
5.4.430.0330.02919.05
5.4.420.0170.01718.93
5.4.410.0330.02118.96
5.4.400.0190.02619.02
5.4.390.0230.02518.98
5.4.380.0280.03019.02
5.4.370.0230.02219.02
5.4.360.0190.02318.93
5.4.350.0440.01818.98
5.4.340.0300.02519.04
5.4.330.0110.00012.88
5.4.320.0260.02318.96
5.4.310.0130.02219.03
5.4.300.0320.02019.01
5.4.290.0370.01819.05
5.4.280.0470.01719.09
5.4.270.0250.01818.95
5.4.260.0380.02018.98
5.4.250.0410.01818.93
5.4.240.0390.02618.97
5.4.230.0470.02918.96
5.4.220.0320.02318.81
5.4.210.0320.02018.95
5.4.200.0330.02618.89
5.4.190.0410.02118.89
5.4.180.0300.02718.87
5.4.170.0310.02019.03
5.4.160.0320.01718.88
5.4.150.0200.02019.03
5.4.140.0470.01719.05
5.4.130.0400.02318.98
5.4.120.0400.01719.03
5.4.110.0300.02018.93
5.4.100.0270.02218.98
5.4.90.0280.02119.12
5.4.80.0250.02019.08
5.4.70.0280.02319.05
5.4.60.0220.02219.01
5.4.50.0270.01819.01
5.4.40.0420.01619.02
5.4.30.0270.01718.98
5.4.20.0180.02419.06
5.4.10.0300.02219.04
5.4.00.0320.01518.81
5.3.290.0320.02319.28
5.3.280.0200.02419.20
5.3.270.0260.02119.21
5.3.260.0340.02019.16
5.3.250.0210.02919.07
5.3.240.0170.02719.06
5.3.230.0370.02219.07
5.3.220.0360.01819.07
5.3.210.0220.02919.11
5.3.200.0100.02719.03
5.3.190.0300.01819.16
5.3.180.0190.01919.13
5.3.170.0240.01719.19
5.3.160.0330.01919.28
5.3.150.0300.02219.16
5.3.140.0370.02319.21
5.3.130.0320.01919.10
5.3.120.0320.01719.23
5.3.110.0410.01219.12
5.3.100.0220.02419.13
5.3.90.0360.02319.12
5.3.80.0280.02519.04
5.3.70.0320.02319.13
5.3.60.0260.02619.07
5.3.50.0200.02219.16
5.3.40.0280.02319.14
5.3.30.0170.02119.14
5.3.20.0270.02219.14
5.3.10.0350.01818.95
5.3.00.0120.02618.97
5.2.170.0280.01718.66
5.2.160.0220.01718.64
5.2.150.0220.02418.64
5.2.140.0200.01818.55
5.2.130.0210.01818.64
5.2.120.0270.01218.56
5.2.110.0210.02818.65
5.2.100.0280.01618.65
5.2.90.0180.01318.52
5.2.80.0200.01718.46
5.2.70.0280.01618.45
5.2.60.0260.01918.58
5.2.50.0430.01518.58
5.2.40.0160.01718.51
5.2.30.0210.02118.58
5.2.20.0100.01518.44
5.2.10.0170.02118.41
5.2.00.0270.01518.37
5.1.60.0270.01218.02
5.1.50.0110.02118.02
5.1.40.0150.01618.08
5.1.30.0130.01618.10
5.1.20.0350.01818.09
5.1.10.0130.01818.09
5.1.00.0020.01917.99
5.0.50.0100.01317.83
5.0.40.0210.01117.83
5.0.30.0180.01517.83
5.0.20.0110.01117.83
5.0.10.0180.01217.83
5.0.00.0180.01817.83
4.4.90.0100.01017.83
4.4.80.0240.00817.83
4.4.70.0080.01217.83
4.4.60.0070.00717.83
4.4.50.0110.00817.83
4.4.40.0070.01217.83
4.4.30.0080.00817.83
4.4.20.0170.01017.83
4.4.10.0120.00717.83
4.4.00.0050.01217.83
4.3.110.0080.01217.83
4.3.100.0120.00817.83
4.3.90.0130.00817.83
4.3.80.0090.01317.83
4.3.70.0030.01117.83
4.3.60.0130.01217.83
4.3.50.0210.00717.83
4.3.40.0140.01217.83
4.3.30.0030.01017.83
4.3.20.0120.00717.83
4.3.10.0020.00917.83
4.3.00.0030.01017.83

preferences:
48.73 ms | 401 KiB | 5 Q