package for detecting users contry in php? [closed

2019-01-15 21:43发布

问题:

I want to know what is the best package to detect country which user is visiting from?

I am using php/mysql..

回答1:

I think there is not a guaranteed way but there are some options:

  • You can use GeoIP
  • You can check the HTTP_ACCEPT_LANGUAGE header($_SERVER)
  • Use any IP-To-Country database


回答2:

You can download the MaxMind GeoLite Country database, and use that to lookup the IP of user to determine their country.

There are paid versions of that database, but I've found the accuracy of the free database more than sufficient.



标签: php ip country