3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function visitor_country() { $ip = $_SERVER["REMOTE_ADDR"]; 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']; $result = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip)) ->geoplugin_countryName; return $result <> NULL ? $result : "Unknown"; } echo visitor_country(); // Output Coutry name [Ex: United States] ?>
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Notice: Undefined index: REMOTE_ADDR in /in/p9glH on line 4 Unknown
Output for 5.2.0 - 5.2.17
Notice: Undefined index: REMOTE_ADDR in /in/p9glH on line 4 Unknown
Output for 5.0.0 - 5.1.6
Notice: Undefined index: REMOTE_ADDR in /in/p9glH on line 4 Fatal error: Call to undefined function filter_var() in /in/p9glH on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/p9glH on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/p9glH on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/p9glH on line 10
Process exited with code 255.