Home  >  Article  >  php教程  >  IP地址定位函数

IP地址定位函数

WBOY
WBOYOriginal
2016-06-07 11:45:261380browse

对IpLocation类进行了封装,方便调用。默认使用的是gbk纯真IP地址库文件QQWry。
function IP($ip='',$charset='gbk',$file='QQWry.dat') {<br>     static $_ip    =    array();<br>     if(isset($_ip[$ip])) {<br>         return $_ip[$ip];<br>     }else{<br>         import("ORG.Net.IpLocation");<br>         $iplocation =   new IpLocation($file);<br>         $location   =   $iplocation->getlocation($ip);<br>         $_ip[$ip]    =    $location['country'].$location['area'];<br>     }<br>     if('utf-8' != $charset) {<br>         $_ip[$ip] = iconv($charset,'utf-8',$_ip[$ip]);<br>     }<br>     return $_ip[$ip];<br> }

AD:真正免费,域名+虚机+企业邮箱=0元

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
Previous article:延迟更新_缓存优化Next article:IE6 PNG 半透明