A McGraw Hill Book Plug-in PHP: 100 Power Solutions
By Robin Nixon (McGraw Hill 2010, ISBN 978-0071666596)

Home | About | Buy It | Download | Contact

Select Chapter: 1  2  3  4  5  6  7  8  9 10 11 12

Chapter 12: Plug-in 91 - Get Country By IP

Knowing which country a web visitor is from can be extremely useful to a webmaster. For example, a personal ads site could use this information to match people up from the same country, as could an auction or classifieds website. Or perhaps you have servers in different countries and want to refer visitors to the one nearest to them, or maybe you simply want to show different advertising or other content to different territories. Whatever the reason, this plug-in, which comes with its own data file, will tell you where a surfer is located.

The Figure shows Google's IP number, which has been correctly identified as being located in the US.