PHP 纯真IP数据库查询IP地址信息

先下载一个纯真IP数据库, 安装完整后,将qqwry.dat即IP数据库放在项目拓展位置,例:

调用:

//use net\IpLocation;

include 'IpLocation.php';
$ip = '219.152.56.66';
$ipadress = new IpLocation();//引入IP地址查询类		
$location = $ipadress->getlocation($ip);	
$location['country'] = iconv('gbk','utf-8',$location['country']);//转换字符集
$location['area'] = iconv('gbk','utf-8',$location['area']);//转换字符集
echo '
';print_r($location);

结果:

Array
(
    [ip] => 219.152.56.66
    [beginip] => 219.152.55.0
    [endip] => 219.152.62.255
    [country] => 重庆市渝北区
    [area] => 电信
)

你可能感兴趣的:(php)