Per esempio

Codice PHP:
$ip $_SERVER['REMOTE_ADDR'];

$country file_get_contents('http://api.hostip.info/country.php?ip='.$ip);

echo 
$country