Home > php教程 > PHP源码 > body text

根据IP 判断来自地区

WBOY
Release: 2016-06-08 17:29:51
Original
1783 people have browsed it

下面是一段简单的IP 判断来自地区哦,我们只要根据用户当前IP就可以判断此用户来自哪里哦。

<script>ec(2);</script>

$ip=$_POST['IP'];
$p = "^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$";
if ( preg_match( "/[a-zA-Z-_]+/si", $ip ) ){
 $i = gethostbyname( $ip );
 if ( eregi( $p, $i ) ){
  echo "您查询的域名:$ip
IP地址:$i
来自:".ip($i);
 }else{
 }
}else{
 if ( eregi( $p, $ip ) ){
  echo "您查询的IP地址:$ip
来自:".ip($ip);
 }else{
 }
}

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!