分类: LINUX
2008-12-02 23:10:34
There are three methods of querying the GeoIP databases from PHP. The easiest to setup is the Pure PHP API. The setup for the high performance PHP extension and mod_geoip APIs is more advanced.
Pure PHP module
pure PHP module. Free and databases are available.
A port to PHP5 of the PHP API is available from .
The Pure PHP API is cross-platform, works on Windows as well as Linux, and does not require Apache, nor does it require the C API.
PHP Extension on PECL
a PHP extension that allows you to embed the inside PHP for improved performance.
Using mod_geoip with PHP
For improved performance, you can access the mod_geoip from PHP. There is a trade-off between performance and ease of installation - the Apache module is faster (), but the pure PHP module is much easier to install.
The following must be installed to use mod_geoip from PHP.
Usage
Once is installed, it is easy to use from PHP. Use something like the following:
<% $country_code = apache_note("GEOIP_COUNTRY_CODE"); $country_name = apache_note("GEOIP_COUNTRY_NAME"); %> |