3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ip_info($ip = NULL, $purpose = "location", $deep_detect = TRUE) { $output = NULL; if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) { $ip = $_SERVER["REMOTE_ADDR"]; if ($deep_detect) { if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) $ip = $_SERVER['HTTP_CLIENT_IP']; } } $purpose = str_replace(array("name", "\n", "\t", " ", "-", "_"), NULL, strtolower(trim($purpose))); $support = array("country", "countrycode", "state", "region", "city", "location", "address"); $continents = array( "AF" => "Africa", "AN" => "Antarctica", "AS" => "Asia", "EU" => "Europe", "OC" => "Australia (Oceania)", "NA" => "North America", "SA" => "South America" ); if (filter_var($ip, FILTER_VALIDATE_IP) && in_array($purpose, $support)) { $ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip)); if (@strlen(trim($ipdat->geoplugin_countryCode)) == 2) { switch ($purpose) { case "location": $output = array( "city" => @$ipdat->geoplugin_city, "state" => @$ipdat->geoplugin_regionName, "country" => @$ipdat->geoplugin_countryName, "country_code" => @$ipdat->geoplugin_countryCode, "continent" => @$continents[strtoupper($ipdat->geoplugin_continentCode)], "continent_code" => @$ipdat->geoplugin_continentCode ); break; case "address": $address = array($ipdat->geoplugin_countryName); if (@strlen($ipdat->geoplugin_regionName) >= 1) $address[] = $ipdat->geoplugin_regionName; if (@strlen($ipdat->geoplugin_city) >= 1) $address[] = $ipdat->geoplugin_city; $output = implode(", ", array_reverse($address)); break; case "city": $output = @$ipdat->geoplugin_city; break; case "state": $output = @$ipdat->geoplugin_regionName; break; case "region": $output = @$ipdat->geoplugin_regionName; break; case "country": $output = @$ipdat->geoplugin_countryName; break; case "countrycode": $output = @$ipdat->geoplugin_countryCode; break; } } } return $output; } $ipinfo = ip_info($_SERVER['REMOTE_ADDR']); echo $ipinfo['country_code'];

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.01116.75
8.3.50.0180.00416.63
8.3.40.0120.00318.98
8.3.30.0100.00618.68
8.3.20.0090.00018.73
8.3.10.0050.00321.48
8.3.00.0060.00319.14
8.2.180.0090.00618.29
8.2.170.0140.00022.96
8.2.160.0110.00719.18
8.2.150.0040.00424.18
8.2.140.0120.00024.66
8.2.130.0080.00026.16
8.2.120.0050.00319.85
8.2.110.0090.00020.97
8.2.100.0080.00418.03
8.2.90.0080.00018.00
8.2.80.0080.00018.91
8.2.70.0040.00418.05
8.2.60.0040.00417.93
8.2.50.0080.00018.10
8.2.40.0050.00320.42
8.2.30.0000.00820.56
8.2.20.0040.00417.72
8.2.10.0040.00418.20
8.2.00.0080.00318.23
8.1.280.0070.01425.92
8.1.270.0000.00823.89
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00619.63
8.1.230.0060.00617.95
8.1.220.0080.00017.91
8.1.210.0000.00818.77
8.1.200.0000.00817.48
8.1.190.0050.00317.23
8.1.180.0040.00418.10
8.1.170.0000.00818.56
8.1.160.0030.00322.11
8.1.150.0060.00318.76
8.1.140.0000.00819.60
8.1.130.0050.00517.72
8.1.120.0000.00817.50
8.1.110.0030.00517.53
8.1.100.0040.00417.50
8.1.90.0030.00617.54
8.1.80.0040.00417.41
8.1.70.0000.00717.40
8.1.60.0040.00417.68
8.1.50.0000.00817.57
8.1.40.0080.00017.58
8.1.30.0050.00317.62
8.1.20.0040.00417.73
8.1.10.0030.00517.44
8.1.00.0080.00017.48
8.0.300.0090.00018.77
8.0.290.0040.00416.88
8.0.280.0030.00318.49
8.0.270.0040.00418.13
8.0.260.0000.00717.34
8.0.250.0070.00017.13
8.0.240.0030.00317.06
8.0.230.0030.00316.94
8.0.220.0030.00516.91
8.0.210.0040.00416.89
8.0.200.0000.00817.07
8.0.190.0040.00417.00
8.0.180.0050.00217.08
8.0.170.0040.00416.94
8.0.160.0040.00416.93
8.0.150.0000.00716.93
8.0.140.0000.00817.01
8.0.130.0030.00313.42
8.0.120.0030.00616.96
8.0.110.0080.00016.92
8.0.100.0030.00517.00
8.0.90.0040.00417.08
8.0.80.0060.00917.05
8.0.70.0050.00317.03
8.0.60.0080.00016.85
8.0.50.0000.00716.88
8.0.30.0110.00817.17
8.0.20.0090.01217.43
8.0.10.0070.00016.94
8.0.00.0090.00916.87
7.4.330.0060.00015.08
7.4.320.0030.00316.70
7.4.300.0000.00716.71
7.4.290.0040.00416.63
7.4.280.0000.00916.67
7.4.270.0000.00716.66
7.4.260.0050.00216.69
7.4.250.0040.00416.64
7.4.240.0020.00516.69
7.4.230.0030.00516.64
7.4.220.0110.00716.64
7.4.210.0050.01016.66
7.4.200.0050.00216.55
7.4.160.0090.00616.58
7.4.150.0060.01217.40
7.4.140.0050.01317.86
7.4.130.0140.00316.51
7.4.120.0070.00916.69
7.4.110.0140.00316.68
7.4.100.0000.01716.50
7.4.90.0110.00616.63
7.4.80.0070.01019.39
7.4.70.0060.00916.44
7.4.60.0030.01316.44
7.4.50.0070.00416.66
7.4.40.0100.00616.73
7.4.30.0070.01016.65
7.4.00.0030.01315.26
7.3.330.0020.00213.17
7.3.320.0030.00313.20
7.3.310.0040.00416.40
7.3.300.0030.00516.41
7.3.290.0000.00716.41
7.3.280.0100.00816.37
7.3.270.0110.00817.40
7.3.260.0140.00716.33
7.3.250.0110.00716.45
7.3.240.0120.00716.47
7.3.230.0080.00816.42
7.3.210.0060.01116.53
7.3.200.0070.01016.38
7.3.190.0110.00616.34
7.3.180.0120.00416.37
7.3.170.0150.00316.35
7.3.160.0030.01216.35
7.2.330.0140.00416.76
7.2.320.0130.00316.49
7.2.310.0070.01016.63
7.2.300.0290.01916.55
7.2.290.0100.00716.57
7.2.60.0000.01516.88
7.2.00.0090.00919.44
7.1.200.0040.01115.91
7.1.100.0060.00617.88
7.1.70.0030.01017.09
7.1.60.0080.00420.41
7.1.00.0030.07322.47
7.0.200.0350.00715.08
7.0.60.0170.08021.70
7.0.50.0070.06320.38
7.0.40.0300.04720.39
7.0.30.0400.05720.40
7.0.20.0400.05720.41
7.0.10.0430.05720.42
7.0.00.0330.05320.36
5.6.280.0000.07320.92
5.6.210.0100.08320.73
5.6.200.0100.04318.16
5.6.190.0170.06021.18
5.6.180.0370.05321.19
5.6.170.0330.06321.11
5.6.160.0330.05721.12
5.6.150.0330.05321.07
5.6.140.0500.07020.93
5.6.130.0300.05721.07
5.6.120.0070.06321.13
5.6.110.0100.06321.07
5.6.100.0270.06321.08
5.6.90.0230.06720.95
5.6.80.0270.05720.52
5.6.70.0300.05320.56
5.6.60.0330.05020.55
5.6.50.0170.06720.50
5.6.40.0270.06020.51
5.6.30.0100.06020.44
5.6.20.0130.05720.38
5.6.10.0170.06020.51
5.6.00.0170.05320.43
5.5.350.3770.03320.52
5.5.340.0070.05018.09
5.5.330.0170.05720.87
5.5.320.0370.05320.88
5.5.310.0370.06020.91
5.5.300.0370.07020.94
5.5.290.0270.05720.82
5.5.280.0100.06320.89
5.5.270.0070.06320.80
5.5.260.0300.06020.86
5.5.250.0200.05720.72
5.5.240.0130.06020.32
5.5.230.0200.06320.20
5.5.220.0300.05320.41
5.5.210.0370.05020.23
5.5.200.0330.05020.26
5.5.190.0300.05320.27
5.5.180.0230.05020.20
5.5.160.0200.05320.25
5.5.150.0130.05720.41
5.5.140.0270.04320.39
5.5.130.0170.04720.22
5.5.120.0170.05320.30
5.5.110.0130.05720.21
5.5.100.0200.05320.21
5.5.90.0130.05320.05
5.5.80.0230.05020.14
5.5.70.0100.06320.14
5.5.60.0270.04319.95
5.5.50.0030.06320.18
5.5.40.0170.05320.13
5.5.30.0200.05020.17
5.5.20.0100.05720.08
5.5.10.0170.05720.19
5.5.00.0270.04720.19

preferences:
63.63 ms | 401 KiB | 5 Q