PHP获取访问设备信息的方法示例
本文实例讲述了PHP获取访问设备信息的方法。分享给大家供大家参考,具体如下:
get_onlineip();
}else{
return$tip;
}
}
////根据ip获得访客所在地地名
functionGetaddress($ip='')
{
if(empty($ip)){
$ip=$this->Getip();
}
$ipadd=file_get_contents("http://int.dpool.sina.com.cn/iplookup/iplookup.php?ip=".$ip);//根据新浪api接口获取
if($ipadd){
$charset=iconv("gbk","utf-8",$ipadd);
preg_match_all("/[\x{4e00}-\x{9fa5}]+/u",$charset,$ipadds);
return$ipadds;//返回一个二维数组
}else{
return"addreeisnone";
}
}
//获得本地真实IP
//functionget_onlineip()
//{
//$mip=file_get_contents("http://city.ip138.com/city0.asp");
//if($mip){
//preg_match("/\[.*\]/",$mip,$sip);
//$p=array(
//"/\[/",
//"/\]/"
//);
//returnpreg_replace($p,"",$sip[0]);
//}else{
//return"获取本地IP失败!";
//}
//}
}
//$info=newget_equipment_info();
//echojson_decode($info->GetLang());
//echojson_decode($info->GetOs());
//echojson_decode($info->GetBrowser());
//print_r($info->Getaddress());
//echo$info->Getip();
//echo$info->get_onlineip();
//die;
?>
更多关于PHP相关内容感兴趣的读者可查看本站专题:《PHP网络编程技巧总结》、《php正则表达式用法总结》、《phpcurl用法总结》、《PHP数组(Array)操作技巧大全》、《php字符串(string)用法总结》、《PHP数据结构与算法教程》、《php程序设计算法总结》、《PHP数学运算技巧总结》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
