Net_GeoIP::lookupCountryCode() --
returns 2-letter country code (e.g.
"CA") for
specified IP address
Description
This method returns the 2-letter country code for the given IP
address. It works with both the free and the non-free databases.
Example 48-1.
Looking up the country code
require_once "Net/GeoIP.php";
$geoip = Net_GeoIP::getInstance("/path/to/geoipdb.dat");
try {
echo $geoip->lookupCountryCode($_SERVER['REMOTE_ADDR']);
} catch (Exception $e) {
// Handle exception
} |
|
Throws
This method throws an exception if the IP address is invalid
or if the database type is incorrect.