26 pers. connectées au site
Manuel Pear
Net_GeoIP::lookupLocation()
Net_GeoIP::lookupLocation() -- returns the location record for specified IP address
Synopsis
- <?php
- require_once "Net/GeoIP.php
- ?>
object lookupLocation() (string $addr)
Description
This method returns an instance of Net_GeoIP_Location for the specified IP address. It works only with a non-free City database.
Exemple 54-1. Looking up the location record
- <?php
- require_once "Net/GeoIP.php";
-
- $geoip = Net_GeoIP::getInstance("/path/to/geoipdb.dat");
-
- try {
- $location = $geoip->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) {
-
- ?>
|
Valeurs renvoyées
This method throws an exception if the IP address is invalid.
Remonter