3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getUserIP() { $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = $_SERVER['REMOTE_ADDR']; if(filter_var($client, FILTER_VALIDATE_IP)) { $ip = $client; } elseif(filter_var($forward, FILTER_VALIDATE_IP)) { $ip = $forward; } else { $ip = $remote; } return $ip; } $ipAddr = getUserIP(); $geoIP = json_decode(file_get_contents("http://freegeoip.net/json/$ipAddr"), true); echo 'lat: ' . $geoIP['latitude'] . '<br />'; echo 'long: ' . $geoIP['longitude']; ?>
Output for 8.3.0 - 8.3.6
Warning: Undefined array key "REMOTE_ADDR" in /in/XonvS on line 1 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for freegeoip.net failed: System error in /in/XonvS on line 1 Warning: file_get_contents(http://freegeoip.net/json/): Failed to open stream: php_network_getaddresses: getaddrinfo for freegeoip.net failed: System error in /in/XonvS on line 1 Warning: Trying to access array offset on null in /in/XonvS on line 1 lat: <br /> Warning: Trying to access array offset on null in /in/XonvS on line 1 long:
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Warning: Undefined array key "REMOTE_ADDR" in /in/XonvS on line 1 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for freegeoip.net failed: System error in /in/XonvS on line 1 Warning: file_get_contents(http://freegeoip.net/json/): Failed to open stream: php_network_getaddresses: getaddrinfo for freegeoip.net failed: System error in /in/XonvS on line 1 Warning: Trying to access array offset on value of type null in /in/XonvS on line 1 lat: <br /> Warning: Trying to access array offset on value of type null in /in/XonvS on line 1 long:
Output for 8.0.13 - 8.0.30
Warning: Undefined array key "REMOTE_ADDR" in /in/XonvS on line 1 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/XonvS on line 1 Warning: file_get_contents(http://freegeoip.net/json/): Failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/XonvS on line 1 Warning: Trying to access array offset on value of type null in /in/XonvS on line 1 lat: <br /> Warning: Trying to access array offset on value of type null in /in/XonvS on line 1 long:
Output for 8.0.0 - 8.0.12
Warning: Undefined array key "REMOTE_ADDR" in /in/XonvS on line 1 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/XonvS on line 1 Warning: file_get_contents(http://freegeoip.net/json/): Failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/XonvS on line 1 Warning: Trying to access array offset on value of type null in /in/XonvS on line 1 lat: <br /> Warning: Trying to access array offset on value of type null in /in/XonvS on line 1 long:
Output for 7.4.0 - 7.4.1, 7.4.26 - 7.4.33
Notice: Undefined index: REMOTE_ADDR in /in/XonvS on line 1 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/XonvS on line 1 Warning: file_get_contents(http://freegeoip.net/json/): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/XonvS on line 1 Notice: Trying to access array offset on value of type null in /in/XonvS on line 1 lat: <br /> Notice: Trying to access array offset on value of type null in /in/XonvS on line 1 long:
Output for 7.4.3 - 7.4.25
Notice: Undefined index: REMOTE_ADDR in /in/XonvS on line 1 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/XonvS on line 1 Warning: file_get_contents(http://freegeoip.net/json/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/XonvS on line 1 Notice: Trying to access array offset on value of type null in /in/XonvS on line 1 lat: <br /> Notice: Trying to access array offset on value of type null in /in/XonvS on line 1 long:
Output for 7.3.32 - 7.3.33
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/XonvS on line 1 Warning: file_get_contents(http://freegeoip.net/json/): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/XonvS on line 1 lat: <br />long:
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31
Notice: Undefined index: REMOTE_ADDR in /in/XonvS on line 1 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/XonvS on line 1 Warning: file_get_contents(http://freegeoip.net/json/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/XonvS on line 1 lat: <br />long:
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.26, 7.3.0 - 7.3.13
Notice: Undefined index: REMOTE_ADDR in /in/XonvS on line 1 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/XonvS on line 1 Warning: file_get_contents(http://freegeoip.net/json/): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/XonvS on line 1 lat: <br />long:

preferences:
256.92 ms | 403 KiB | 375 Q