Heim  >  Artikel  >  php教程  >  ip地址归属地接口

ip地址归属地接口

WBOY
WBOYOriginal
2016-06-06 19:34:081380Durchsuche

返回归属地 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的地址信息
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn