开发者

IP To Country in PHP [duplicate]

This question already has answers here: 开发者_StackOverflow Closed 12 years ago.

Possible Duplicate:

IP to Country?

What is the best way to get country from given IP in PHP?


Take a look at:

The IP-to-Country Handbook

You can download this free database

Once you have imported the database, you need to run this query to get country from the IP:

 $country_query  = "SELECT country_code2,country_name FROM iptoc
                    WHERE IP_FROM<='$REMOTE_ADDR' AND IP_TO>='$REMOTE_ADDR'";


You can use one of the free IP address geolocation tools existing, like the one at http://ipinfodb.com/ip_location_api.php.

It is very easy to use, having example for many programming languages, as well as some modules for different content management systems (wordpress, drupal, joomla).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜