3v4l.org

run code in 300+ PHP versions simultaneously
<?php // --------------------------- DETECT CITY BY IP --------------------------- // function detect_city($ip) { $default = 'UNKNOWN'; if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost') $ip = '8.8.8.8'; $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'; $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip); $ch = curl_init(); $curl_opt = array( CURLOPT_FOLLOWLOCATION => 1, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_USERAGENT => $curlopt_useragent, CURLOPT_URL => $url, CURLOPT_TIMEOUT => 1, CURLOPT_REFERER => 'http://' . $_SERVER['HTTP_HOST'], ); curl_setopt_array($ch, $curl_opt); $content = curl_exec($ch); if (!is_null($curl_info)) { $curl_info = curl_getinfo($ch); } curl_close($ch); if ( preg_match('{<li>City : ([^<]*)</li>}i', $content, $regs) ) { $city = $regs[1]; } if ( preg_match('{<li>State/Province : ([^<]*)</li>}i', $content, $regs) ) { $state = $regs[1]; } if( $city!='' && $state!='' ){ $location = $city . ', ' . $state; return $location; }else{ return $default; } } $ip = "87.224.117.53"; echo detect_city($ip); ?>

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.0110.00821.21
8.3.40.0090.00618.98
8.3.30.0060.00820.34
8.3.20.0000.00820.10
8.3.10.0080.00021.95
8.3.00.0000.00822.43
8.2.180.0070.01417.00
8.2.170.0190.00322.96
8.2.160.0040.01122.08
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0050.00320.72
8.2.110.0060.00319.26
8.2.100.0120.00017.84
8.2.90.0040.00418.95
8.2.80.0040.00419.14
8.2.70.0030.00617.63
8.2.60.0040.00418.01
8.2.50.0030.00518.07
8.2.40.0000.00918.21
8.2.30.0070.00019.47
8.2.20.0040.00417.72
8.2.10.0080.00017.75
8.2.00.0070.00017.87
8.1.280.0070.01125.92
8.1.270.0060.00323.99
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0050.00522.14
8.1.230.0110.00020.88
8.1.220.0040.00418.55
8.1.210.0000.00919.15
8.1.200.0030.00617.23
8.1.190.0040.00417.52
8.1.180.0050.00318.10
8.1.170.0000.00818.50
8.1.160.0040.00718.90
8.1.150.0040.00418.70
8.1.140.0000.00717.42
8.1.130.0030.00317.88
8.1.120.0000.00717.52
8.1.110.0050.00217.38
8.1.100.0070.00017.43
8.1.90.0000.00717.50
8.1.80.0040.00417.40
8.1.70.0030.00317.45
8.1.60.0080.00017.53
8.1.50.0000.00717.54
8.1.40.0110.00017.61
8.1.30.0030.00517.64
8.1.20.0040.00417.62
8.1.10.0000.00817.56
8.1.00.0040.00417.58
8.0.300.0040.00420.16
8.0.290.0070.00017.29
8.0.280.0030.00318.44
8.0.270.0030.00317.32
8.0.260.0000.00717.04
8.0.250.0000.00717.06
8.0.240.0050.00317.02
8.0.230.0040.00417.09
8.0.220.0030.00317.00
8.0.210.0000.00717.05
8.0.200.0030.00317.05
8.0.190.0030.00617.11
8.0.180.0070.00017.02
8.0.170.0040.00416.96
8.0.160.0050.00216.86
8.0.150.0030.00316.84
8.0.140.0060.00316.88
8.0.130.0030.00313.41
8.0.120.0000.00916.88
8.0.110.0040.00416.85
8.0.100.0080.00016.98
8.0.90.0040.00417.02
8.0.80.0130.01017.05
8.0.70.0000.00716.98
8.0.60.0000.00717.03
8.0.50.0000.00816.94
8.0.30.0120.00717.15
8.0.20.0110.00917.40
8.0.10.0040.00417.06
8.0.00.0110.00816.92
7.4.330.0000.00516.69
7.4.320.0030.00316.57
7.4.300.0080.00016.66
7.4.290.0050.00316.58
7.4.280.0070.00016.55
7.4.270.0030.00316.66
7.4.260.0000.00613.41
7.4.250.0040.00416.53
7.4.240.0050.00216.55
7.4.230.0000.00716.59
7.4.220.0080.01116.66
7.4.210.0090.00516.66
7.4.200.0030.00316.36
7.4.190.0000.00716.42
7.4.160.0130.00416.69
7.4.150.0130.00717.40
7.4.140.0050.01317.86
7.4.130.0110.00616.67
7.4.120.0120.00816.53
7.4.110.0030.01316.47
7.4.100.0110.00516.73
7.4.90.0100.00716.66
7.4.80.0100.00919.39
7.4.70.0130.00316.39
7.4.60.0180.01516.46
7.4.50.0040.00416.75
7.4.40.0100.00722.77
7.4.30.0100.00716.54
7.4.00.0060.01015.09
7.3.330.0060.00013.48
7.3.320.0020.00213.27
7.3.310.0030.00416.48
7.3.300.0060.00016.47
7.3.290.0040.01016.45
7.3.280.0090.00716.49
7.3.270.0070.01017.40
7.3.260.0090.00918.24
7.3.250.0080.01216.52
7.3.240.0150.00616.41
7.3.230.0100.00716.56
7.3.210.0100.00716.54
7.3.200.0110.00619.39
7.3.190.0090.00916.67
7.3.180.0130.00716.61
7.3.170.0120.00916.43
7.3.160.0120.00916.40
7.3.120.0100.00614.93
7.2.330.0140.00416.52
7.2.320.0090.00916.81
7.2.310.0100.00716.56
7.2.300.0070.01416.83
7.2.290.0170.00016.75
7.2.80.0040.00416.61
7.2.60.0000.01016.95
7.2.00.0030.01019.39
7.1.200.0060.00615.62
7.1.100.0040.00818.11
7.1.70.0000.01017.17
7.1.60.0070.01919.17
7.1.50.0070.01416.98
7.1.00.0030.07022.33
7.0.200.0070.00316.91
7.0.140.0030.09322.01
7.0.100.0100.07720.01
7.0.90.0100.07319.87
7.0.80.0070.04319.88
7.0.70.0000.08319.84
7.0.60.0070.06320.05
7.0.50.0200.06320.30
7.0.40.0070.07320.05
7.0.30.0130.08020.01
7.0.20.0070.08720.09
7.0.10.0070.04320.00
7.0.00.0030.05719.98
5.6.280.0000.07721.09
5.6.250.0030.08320.57
5.6.240.0070.06020.60
5.6.230.0130.07320.57
5.6.220.0200.07720.64
5.6.210.0070.07020.72
5.6.200.0070.08721.02
5.6.190.0170.07321.04
5.6.180.0070.08321.08
5.6.170.0130.07721.02
5.6.160.0070.06020.93
5.6.150.0100.05021.08
5.6.140.0070.08320.91
5.6.130.0070.06721.07
5.6.120.0030.08021.01
5.6.110.0070.07721.02
5.6.100.0100.07021.04
5.6.90.0130.07720.90
5.6.80.0070.08020.36
5.6.70.0030.04720.37
5.6.60.0030.08020.28
5.6.50.0070.08020.30
5.6.40.0070.08020.46
5.6.30.0030.08320.36
5.6.20.0070.08020.46
5.6.10.0070.08020.50
5.6.00.0000.08320.40
5.5.380.0000.08720.37
5.5.370.0070.07720.48
5.5.360.0170.07720.40
5.5.350.0100.06320.42
5.5.340.0200.05720.61
5.5.330.0030.09320.90
5.5.320.0170.07720.73
5.5.310.0130.07020.75
5.5.300.0030.07320.89
5.5.290.0130.07320.86
5.5.280.0070.07020.89
5.5.270.0170.07720.86
5.5.260.0100.08020.84
5.5.250.0100.07320.58
5.5.240.0100.07320.25
5.5.230.0130.07320.24
5.5.220.0030.07019.98
5.5.210.0070.08320.17
5.5.200.0200.06720.24
5.5.190.0100.06320.23
5.5.180.0070.08020.08
5.5.160.0100.07320.05
5.5.150.0170.04020.15
5.5.140.0170.06720.14
5.5.130.0030.06320.23
5.5.120.0000.05019.96
5.5.110.0130.07720.05
5.5.100.0100.06720.02
5.5.90.0100.07020.08
5.5.80.0130.07019.98
5.5.70.0170.07320.12
5.5.60.0200.06720.12
5.5.50.0170.06720.07
5.5.40.0000.07719.97
5.5.30.0130.06719.89
5.5.20.0100.08320.09
5.5.10.0130.07720.11
5.5.00.0100.06020.10
5.4.450.0100.06719.25
5.4.440.0100.06719.54
5.4.430.0070.07719.53
5.4.420.0100.07019.37
5.4.410.0070.08019.24
5.4.400.0030.05719.04
5.4.390.0100.07319.10
5.4.380.0270.03019.24
5.4.370.0100.07319.24
5.4.360.0200.06319.04
5.4.350.0100.07019.18
5.4.340.0130.07019.13
5.4.320.0000.08318.86
5.4.310.0030.06019.09
5.4.300.0030.07719.23
5.4.290.0130.04018.88
5.4.280.0030.06019.03
5.4.270.0070.07719.18
5.4.260.0070.07018.86
5.4.250.0130.07019.03
5.4.240.0130.07019.13
5.4.230.0030.08019.18
5.4.220.0130.07018.88
5.4.210.0070.07718.87
5.4.200.0070.07019.04
5.4.190.0070.04719.18
5.4.180.0070.08719.24
5.4.170.0070.07319.20
5.4.160.0030.07719.16
5.4.150.0170.07019.15
5.4.140.0030.07316.39
5.4.130.0130.06716.36
5.4.120.0100.05716.36
5.4.110.0100.07016.47
5.4.100.0000.05016.34
5.4.90.0030.08016.50
5.4.80.0070.06316.46
5.4.70.0030.07316.27
5.4.60.0030.08016.49
5.4.50.0000.04716.34
5.4.40.0030.07716.54
5.4.30.0070.07016.42
5.4.20.0100.06316.27
5.4.10.0100.06716.37
5.4.00.0070.07315.81
5.3.290.0070.07314.77
5.3.280.0130.07014.66
5.3.270.0130.07314.55
5.3.260.0030.07014.60
5.3.250.0070.07014.69
5.3.240.0130.06714.65
5.3.230.0030.06714.67
5.3.220.0070.07014.59
5.3.210.0170.06314.63
5.3.200.0100.07314.59
5.3.190.0070.07714.56
5.3.180.0100.06714.68
5.3.170.0070.07714.54
5.3.160.0070.06014.64
5.3.150.0030.06014.72
5.3.140.0200.06314.71
5.3.130.0030.05714.64
5.3.120.0030.08014.63
5.3.110.0070.04714.68
5.3.100.0030.08014.04
5.3.90.0000.07314.02
5.3.80.0070.06013.96
5.3.70.0070.07714.04
5.3.60.0130.06014.13
5.3.50.0070.07314.02
5.3.40.0100.07314.03
5.3.30.0030.06714.02
5.3.20.0070.07313.76
5.3.10.0000.04313.59
5.3.00.0070.07313.75
5.2.170.0030.05011.28
5.2.160.0030.07311.23
5.2.150.0000.05011.18
5.2.140.0030.03711.07
5.2.130.0030.06711.04
5.2.120.0100.05011.21
5.2.110.0000.05311.25
5.2.100.0000.06311.20
5.2.90.0100.05311.02
5.2.80.0000.06711.13
5.2.70.0030.07010.99
5.2.60.0000.04710.97
5.2.50.0070.05310.90
5.2.40.0000.06710.92
5.2.30.0000.06311.00
5.2.20.0030.06010.93
5.2.10.0000.06010.81
5.2.00.0030.03710.72
5.1.60.0100.05010.10
5.1.50.0070.05010.02
5.1.40.0030.05010.10
5.1.30.0130.04010.49
5.1.20.0100.04710.48
5.1.10.0100.05010.19
5.1.00.0030.05010.14
5.0.50.0030.0438.65
5.0.40.0000.0308.44
5.0.30.0100.0408.25
5.0.20.0070.0408.23
5.0.10.0030.0438.26
5.0.00.0100.0408.24
4.4.90.0100.0278.23
4.4.80.0030.0278.23
4.4.70.0070.0338.23
4.4.60.0030.0338.23
4.4.50.0070.0178.23
4.4.40.0000.0578.23
4.4.30.0070.0308.23
4.4.20.0030.0338.23
4.4.10.0030.0308.23
4.4.00.0000.0338.23
4.3.110.0000.0378.23
4.3.100.0030.0178.23
4.3.90.0030.0208.23
4.3.80.0000.0538.23
4.3.70.0030.0338.23
4.3.60.0070.0238.23
4.3.50.0030.0278.23
4.3.40.0000.0438.23
4.3.30.0030.0208.23
4.3.20.0030.0338.23
4.3.10.0030.0178.23
4.3.00.0000.0238.23

preferences:
42.99 ms | 401 KiB | 5 Q