首頁  >  文章  >  php教程  >  ip地址归属地接口

ip地址归属地接口

WBOY
WBOY原創
2016-06-06 19:34:081380瀏覽

返回归属地 isp 等ip地址信息 指定ip时会显示指定ip的地址信息Array ( [ret] = 1 [start] = 124.128.0.0 [end] = 124.128.255.255 [country] = 中国 [province] = 山东 [city] = 济南 [district] = [isp] = 联通 [type] = [desc] =) 不知道时,会显示运行代码

返回归属地 isp 等ip地址信息
指定ip时会显示指定ip的地址信息Array ( [ret] => 1 [start] => 124.128.0.0 [end] => 124.128.255.255 [country] => 中国 [province] => 山东 [city] => 济南 [district] => [isp] => 联通 [type] => [desc] => )
不知道时,会显示运行代码的服务器ip地址信息 CorePHP
function ip2add($ip=''){
$json = file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip='.$ip);
$address = json_decode($json,true);
return $address;
}
print_r(ip2add());//会显示服务器的ip地址信息
print_r(ip2add('124.128.61.235'));//显示指定ip的地址信息
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn