[Official Release] IP2Location PHP API to get location info from IPv4 and IPv6 address.
This is the official release maintained by IP2Location.com
This PHP module provides fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection speed, IDD code, area code, weather station code, weather station name, MNC, MCC, mobile brand, elevation, and usage type from IP address by using IP2Location database. This module uses a file based database available at IP2Location.com.
This module can be used in many types of projects such as:
- select the geographically closest mirror
- analyze your web server logs to determine the countries of your visitors
- credit card fraud detection
- software export controls
- display native language and currency
- prevent password sharing and abuse of service
- geotargeting in advertisement
Free IP2Location LITE and commerical databases are available for download.
- LITE database is available at https://lite.ip2location.com (Free with limited accuracy)
- Commercial database is availabe at https://www.ip2location.com (Comprehensive with high accuracy)
Monthly update is available for both IP2Location LITE and commercial database.
- Support both IPv4 and IPv6 with ease. If you would like to enable IPv6 support, you just need to replace your BIN file with IPv6 version. That's it, and no code modification needed.
- Extensible. If you require different granularity of IP information, you can visit IP2Location.com to download the relevant BIN file, and the information will made ready for you.
- Comprehensive Information. There are more than 13 types of information that you can retrieve from an IP address. Please visit IP2Location.com for details.
To install this module, unzip the package and copy the following files to your web folder.
To test this installation, please browse example.php using web browser.
Below is the description of the functions available in this class
|Constructor||Expect 2 input parameters:
|getDate||Return the database's compilation date as a string of the form 'YYYY-MM-DD'|
|getType||Return the database's type, 1 to 24 respectively for DB1 to DB24. Please visit https://www.ip2location.com/databases for details.|
|getModuleVersion||Return the version of module|
|getDatabaseVersion||Return the version of database|
|lookup||Return the IP information in array. Below is the information returned:
This library requires IP2Location BIN data file to function. You may download the BIN data file at
- IP2Location LITE BIN Data (Free): https://lite.ip2location.com
- IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com
An outdated BIN database was provided in the databases folder for your testing. You are recommended to visit the above links to download the latest BIN database.
- Use the IPv4 BIN file if you just need to query IPv4 addresses.
- Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
Below are the list of other framework library that you can install and use right away.
Copyright (C) 2005-2018 by IP2Location.com
License under MIT