Net_GeoIP::lookupRegion() (Previous) (Next) Net_GeoIP::lookupOrg()

View this page in Last updated: Sun, 28 Sep 2008
English | French | German | Hungarian | Japanese | Polish | Spanish | Plain HTML

Net_GeoIP::lookupLocation()

Net_GeoIP::lookupLocation() --  returns the location record for specified IP address

Parameter

  • string $addr - IP address

    Anmerkung: Hostnames are not supported. More information.

Fehler-Meldungen

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

Net_GeoIP::lookupRegion() (Previous) (Next) Net_GeoIP::lookupOrg()

Download Documentation Last updated: Sun, 28 Sep 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: f.0123.6@gmail.com
Can someone post a example on how to use this filter with the FREE city database (GeoLiteCity.dat).

I got the Country lookup working and thought the city lookup is prcedurally identical, but I guess not.

here is the code that I have for city lookup. am I missing something??


require_once 'PEAR/Net/GeoIP.php';
require_once 'PEAR/Net/GeoIP/Location.php';

$geoipCountry = Net_GeoIP::getInstance('PEAR/Net/GeoIP/GeoIP.dat');
$geoipCity = Net_GeoIP::getInstance('PEAR/Net/GeoIP/GeoLiteCity.dat');



try {
$country_name=$geoipCountry->lookupCountryName($_SERVER['REMOTE_ADDR']);
echo '<br><br>';
echo $country_name;

//$city_name=$geoipCity->lookupLocation($_SERVER['REMOTE_ADDR']);
//echo '<br><br>';
//echo $city_name;

$location=$geoipCity->lookupLocation($_SERVER['REMOTE_ADDR']);
var_dump($location);

printf("City: %s, %s\nLatitude: %s, Longitude: %s\n",
$location->city, $location->region,
$location->latitude, $location->longitude);

}

catch (Exception $e)
{ // Handle exception
}
Note by: Steve_Burner@hotmail.com
It works with the free City database GeoLiteCity.dat
available from www.maxmind.com/app/geolitecity.