Net_GeoIP::lookupRegion()

Net_GeoIP::lookupRegion() – returns the region for given IP address.

Synopsis

require_once "Net/GeoIP.php";

array lookupRegion() ( string $addr )

Description

This method returns an array containing the country code and the region for the specified IP address. It works only with a non-free Region database.

Looking up the region

<?php
require_once "Net/GeoIP.php";

$geoip Net_GeoIP::getInstance("/path/to/geoipdb.dat");

try {
    list(
$country_code$region) = $geoip->lookupRegion($_SERVER['REMOTE_ADDR']);
} catch (
Exception $e) {
    
// Handle exception
}
?>

Parameter

Throws

This method throws an exception if the IP address is invalid.

returns 2-letter country code (e.g. CA) for specified IP address (Previous) returns the location record for specified IP address (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.