Search code examples
phpip-address

Country name from PHP


How to get country name from an IP address using PHP without using a commercial GeoIP Region Edition?


Solution

  • I don't think you can do it simply using PHP, but I have found a free API solution that you can use. It requires simple post and response. http://www.hostip.info/use.html

    example post: http://api.hostip.info/get_html.php?ip=12.215.42.19

    example response: Country: UNITED STATES (US) City: Sugar Grove, IL