PHP Classes

File: sample-IP2Location.php

Recommend this page to a friend!
  Classes of KL Liew   IP2Location   sample-IP2Location.php   Download  
File: sample-IP2Location.php
Role: Example script
Content type: text/plain
Description: Sample PHP Code
Class: IP2Location
Lookup the geographic location of an IP address
Author: By
Last change: a) Support IPv6
b) Support Time Zone and Net Speed
Date: 17 years ago
Size: 1,392 bytes
 

Contents

Class file image Download
#!/usr/bin/php -q
<?php

//
// This code demonstrates how to use to IP2Location BIN database to lookup
// country, region, city, isp, latitude, longitude, domain, zip code
//
// Note: Only Country information will be displayed if the BIN database is IP-COUNTRY.BIN
//
// Copyright (C) 2006 IP2Location.com All Rights Reserved.
//

include("IP2Location.inc");

$ip = IP2Location_open("samples/IP-COUNTRY-SAMPLE.BIN", IP2LOCATION_STANDARD);

$record = IP2Location_get_all($ip, "35.1.1.1");

echo
"\$record->country_short : " . $record->country_short . "<br>";
echo
"\$record->country_long : " . $record->country_long . "<br>";
echo
"\$record->region : " . $record->region . "<br>";
echo
"\$record->city : " . $record->city . "<br>";
echo
"\$record->isp : " . $record->isp . "<br>";
echo
"\$record->latitude : " . $record->latitude . "<br>";
echo
"\$record->longitude : " . $record->longitude . "<br>";
echo
"\$record->domain : " . $record->domain . "<br>";
echo
"\$record->zipcode : " . $record->zipcode . "<br>";
echo
"\$record->timezone : " . $record->timezone . "<br>";
echo
"\$record->netspeed : " . $record->netspeed . "<br>";
echo
"\$record->ipaddr : " . $record->ipaddr . "<br>";
echo
"\$record->ipno : " . $record->ipno . "<br>";

IP2Location_close($ip);

?>
<P><A href="http://www.ip2location.com"><img border=0 src="http://www.ip2location.com/images/ip2location468x60_0.gif"></a></P>