开发者

IP To Country in PHP [duplicate]

开发者 https://www.devze.com 2023-01-27 11:54 出处:网络
This question already has answers here: 开发者_StackOverflow Closed 12 years ago. Possible 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

精彩评论

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