Home >php教程 >php手册 >ip地址归属地接口

ip地址归属地接口

WBOY
WBOYOriginal
2016-06-06 19:34:081447browse

返回归属地 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的地址信息
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn