手机号码归属地查询代码
本款手机号码归属地查询代码是一款php开源手机归属查询系统,本系统不依靠mysql之类的大型数据库,而是依靠文本,因为,一般一个手机号码,在查询系统中起决定作用的就是前7位手机号码归属地查询代码
/*
本款手机号码归属地查询代码是一款php教程开源手机归属查询系统,本系统不依靠mysql教程之类的大型数据库教程,而是依靠文本,因为,一般一个手机号码,在查询系统中起决定作用的就是前7位
*/
if( $_post )
{
$phone=(isset($_post["phone"]))?$_post["phone"]:die ("请返回");
echo "你查询的:$phone,资料:".getphone($phone);
function getphone($phone){
$dbpath="datas/";
$len=strlen($phone);
if ( $len !=11 ){
return "手机号码只支持11位";
}
$par="[0-9]";
for ($i=0;$i<$len;$i++){
if(!ereg($par,substr($phone,$i,1) ) ){
return "手机号码只能为数字";
}
}
$sunum=scandir($dbpath); //得到支持的手机号码前缀
array_splice($sunum,0,1); //把当前目录取消
array_splice($sunum,0,1); //把上一级目录去掉
$sub=substr($phone,0,3); //取得该号码的前三位
if (in_array($sub,$sunum) ){
$num=substr($phone,3,4);
$search=file($dbpath.$sub);
$result=str_replace($num."=","",$search[$num]); //处理数据
return (strlen($result)>1)?$result:"0";}else{
return "暂不支持$sub";
}}
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>手机号码归属地查询</title>
</head>
<body>
<form action="search.php" method="post">
<p>请输入手机号码:<input type="text" name="phone"></p>
<p><input type="submit" value="查询"></p></p>
</form>
</body>
</html>
PHP之友评论