Net_Geo (Previous) (Next) Net_Geo::Net_Geo()

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

Net_Geo - Example

Net_Geo - Example -- tracking down the remote client IP

Example


<?php

require_once('Net/Geo.php');

// new Net_Geo object
$net_geo = new Net_Geo();

// fetch the client's IP
$ip $_SERVER['REMOTE_ADDR'];

// fetch information array from net_geo
$results $net_geo->getRecord($ip);

// output
echo "Single IP results:<br />";
echo "<pre>";
print_r($results);
echo "</pre>";

// example array of multiple IPs
$arr_ips = array
(
  gethostbyname("www.google.com"),
  gethostbyname("www.heise.de"),
  gethostbyname("www.college.ch")
);

// fetch information array from net_geo
$results $net_geo->getRecord($arr_ips);

// output
echo "Multiple IP results:<br />";
echo "<pre>";
print_r($results);
echo "</pre>";

?>

Net_Geo (Previous) (Next) Net_Geo::Net_Geo()

Download Documentation Last updated: Sun, 31 Aug 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: haptiK@gmail.com
Unfortunatly most results returned are so far off the mark it deems the package entirely useless.