php 判断手机号运营商
/*
移动:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188
联通:130、131、132、152、155、156、185、186
电信:133、153、180、189、(1349卫通)
*/
/**
* 手机服务商函数 getphonetype
*@author by @tianxiao
*@param string $phone 手机号字符串
*@return unsignedint 0中国移动,1中国联通 2中国电信 3未知
**/
function getphonetype($phone){
$phone = trim($phone);
$isChinaMobile = "/^134[0-8]\d{7}$|^(?:13[5-9]|147|15[0-27-9]|178|18[2-478])\d{8}$/"; //移动方面最新答复
$isChinaUnion = "/^(?:13[0-2]|145|15[56]|176|18[56])\d{8}$/"; //向联通微博确认并未回复
$isChinaTelcom = "/^(?:133|153|177|173|18[019])\d{8}$/"; //1349号段 电信方面没给出答复,视作不存在
// $isOtherTelphone = "/^170([059])\\d{7}$/";//其他运营商
if(preg_match($isChinaMobile, $phone)){
return 0;
}elseif(preg_match($isChinaUnion, $phone)){
return 1;
}elseif(preg_match($isChinaTelcom, $phone)){
return 2;
}else{
return 3;
}
}
/* 移动:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188 联通:130、131、132、152、155、156、185、186 电信:133、153、180、189、(1349卫通) *//** * 手机服务商函数 getphonetype *@author by @tianxiao *@param string $phone 手机号字符串 *@return unsignedint 0中国移动,1中国联通 2中国电信 3未知 **/function getphonetype($phone){ $phone = trim($phone); $isChinaMobile = "/^134[0-8]\d{7}$|^(?:13[5-9]|147|15[0-27-9]|178|18[2-478])\d{8}$/"; //移动方面最新答复 $isChinaUnion = "/^(?:13[0-2]|145|15[56]|176|18[56])\d{8}$/"; //向联通微博确认并未回复 $isChinaTelcom = "/^(?:133|153|177|173|18[019])\d{8}$/"; //1349号段 电信方面没给出答复,视作不存在 // $isOtherTelphone = "/^170([059])\\d{7}$/";//其他运营商 if(preg_match($isChinaMobile, $phone)){ return 0; }elseif(preg_match($isChinaUnion, $phone)){ return 1; }elseif(preg_match($isChinaTelcom, $phone)){ return 2; }else{ return 3; }}
php 判断手机号运营商的更多相关文章
- PHP判断手机号运营商(详细介绍附代码)
道理很简单,知道手机号规则 进行正则判断就可以 移动:134.135.136.137.138.139.150.151.157(TD).158.159.187.188 联通:130.131.132.15 ...
- 记 判断手机号运营商function
/* 移动:134.135.136.137.138.139.150.151.157(TD).158.159.187.188 联通:130.131.132.152.155.156.185.186 电信: ...
- Android手机上判断网络运营商
我们想获取手机的运营商信息.通常都会去调用系统的TelephonyManager类的取数据.但是很多时候可能取不到卡的信息(例如双卡手机和 一些特殊卡),这样就区别不了运营商了.但是有时候我们的需求要 ...
- PHP 判断手机号归属地 和 运营商的免费接口
在项目开发的时候,需要去查询又一批手机号或者固话的具体信息(归属地 运营商) 就需要写一个脚本,来批量请求接口来得到我们想要的数据 学习源头:https://blog.csdn.net/shaerdo ...
- iOS开发判断手机号及其运营商
根据三大运营商出现的号段(号段来自百度百科) 判断是否是手机号 + (BOOL)isMobile:(NSString *)str { NSString *MOBILE = @"^1(3[0- ...
- android判断网络连接状态、联网类型、运营商
/** * 获取上网方式 * * @param mContext * @return */ public static String getNetType(Context mContext) { St ...
- android 判断是否有sim卡及运营商
判断是否有sim卡的方法: int absent = TelephonyManager.SIM_STATE_ABSENT; if (1 == absent) { Log.d(TAG,"请 ...
- 赵雅智_android获取本机运营商,手机号部分能获取
手机号码不是全部的都能获取.仅仅是有一部分能够拿到. 这个是因为移动运营商没有把手机号码的数据写入到sim卡中.SIM卡仅仅有唯一的编号.供网络与设备 识别那就是IMSI号码,手机的信号也能够说是通过 ...
- Python(phone)模块获取手机号归属地、区号、运营商等
Python(phone)模块获取手机号归属地.区号.运营商等 一.我使用的是python3,可以自行搜索下载 二.安装phone模块, pip install phone 三.测试代码如下: fro ...
随机推荐
- (1366, "Incorrect string value: '\\xF3\\xB0\\x84\\xBC</...' for column 'content' at row 1")
插数据库报错 (1366, "Incorrect string value: '\\xF3\\xB0\\x84\\xBC</...' for column 'content' at r ...
- vue-cookies、极验滑动验证geetest、vue-router的导航守卫
一 . vue-cookies 参考文档简书:https://www.jianshu.com/p/535b53989b39 参考文档npm:https://www.npmjs.com/package/ ...
- html5/CSS3鼠标滑过图片特效插件
在线演示 本地下载
- debian下编译openwrt固件
参考文章:Ubuntu下编译OpenWRT固件 我买的路由器是RG100A-AA,采用了bcm63xx系列的芯片. 下载openwrt源码: svn co svn://svn.openwrt.org/ ...
- 吴恩达机器学习笔记(二) —— Logistic回归
主要内容: 一.回归与分类 二.Logistic模型即sigmoid function 三.decision boundary 决策边界 四.cost function 代价函数 五.梯度下降 六.自 ...
- centos6.3 安装python2.7.3
现在比较流行python2.7版本,centos6.3的默认版本是2.6.6,所以需要安装下2.7版本 1.下载安装python2.7 #wget http://www.python.org/ftp/ ...
- c++queue容器介绍
一.queue模版类的定义在<queue>头文件中. queue与stack模版非常类似,queue模版也需要定义两个模版参数,一个是元素类型,一个是容器类型,元素类型是必要的,容器类型是 ...
- tensorflow knn mnist
# MNIST Digit Prediction with k-Nearest Neighbors #----------------------------------------------- # ...
- leetcode 67. Add Binary (高精度加法)
Given two binary strings, return their sum (also a binary string). For example,a = "11"b = ...
- k8s 部署kube-dns
[root@k8s-master src]# kubectl create -f kube-dns.yaml service "kube-dns" createdserviceac ...