HomePHP Building an IP-to-Country Mapping Application with PHP
Building an IP-to-Country Mapping Application with PHP
If you have content in several different languages, your visitors probably speak several different languages as well. Wouldn't it be nice to serve them content from your site in their native language, based on the country from which they hail? You can, even if you're a small company, with an application that tells you a visitor's country based on their IP address. This four-part article series will show you how to build the application and incorporate it into your web site.
Due to the webís constant evolution, and more specifically, because of the need to get more traffic, itís now common to see web sites delivering their contents in different languages, depending on the countries from which theyíre being accessed.
Google, Yahoo, and Hotmail, to cite a few, are good examples of how big companies implement this feature to offer a greater level of customization to their users all over the world. Even PHPís official web site gives visitors the choice to read the PHP manual using their native languages, which has contributed to expanding its utilization worldwide.
While it is easy for big web players, like the ones mentioned above, to provide their services through a multi-lingual platform, for small and medium-scaled web sites, implementing this feature can be a more complex and challenging task.
Not all is lost in cases like these. Actually, building a small web site that will offer support for several languages might be easier than you think, thanks to the existence of a few IP-to-country mapping databases, which can be freely used during the development of a particular web project.
By way of a mapping database, itís possible to build an IP-to-country application very easily. Such an application can be utilized, for instance, for creating a web site that delivers its contents in distinct languages according to the countries from which visitors are coming.
Currently, there are a few good IP-to-country lookup databases available on the web that can be accessed and used for free, but in this particular tutorial Iím going to pick the one provided by Webnet77 (http://software77.net/cgi-bin/ip-country/geo-ip.pl). It contains more than 87,600 records, which permit you to map over 3,200,000,000 IP addresses to their corresponding countries.Thatís a lot of information and hard work!
In summary, in this group of articles, Iíll be demonstrating how to use the aforementioned database to build an IP-to-country lookup application with PHP, which can be incorporated into any existing web site with minor hassles.
So, want to learn how to spice up you own web site with neat geo-IP location capabilities? Then start reading now!