Heim  >  Artikel  >  php教程  >  IP地址定位函数

IP地址定位函数

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

对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元

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
Vorheriger Artikel:延迟更新_缓存优化Nächster Artikel:IE6 PNG 半透明