地理位置不带扩展名的IP? [英] Geolocate an IP without extensions?
本文介绍了地理位置不带扩展名的IP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以在不使用任何php扩展的情况下找到IP的国家?
Is there a way to locate an IP's country without using any php extensions?
我知道有某些扩展,但这可能不使用扩展或使用其他扩展网站。例如:
I know there are certain extensions, but is this possible without using extensions nor using other websites. For example:
www.[ip to country].[something]/?ip=123.123.123.123
推荐答案
您可以使用
You can use
$url = "http://www.geoplugin.net/json.gp?ip=173.194.41.103";
$json = json_decode(file_get_contents($url));
printf("%s,%s", $json->geoplugin_regionName, $json->geoplugin_countryName);
输出
California,United States
这篇关于地理位置不带扩展名的IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文