设为首页 加入收藏

TOP

PHP手机号正则(多号段)
2019-08-23 00:32:48 】 浏览:18
Tags:PHP 手机号 正则 号段

   public function phoneReg()
   {
/**
* 中国电信:China Telecom
* 133、149、153、173、177、180、181、189、199
*/
$ct = "/^1((33|49|53|73|77|80|81|89|99)[0-9])\d{7}$/";

/**
* 中国联通:China Unicom
* 130、131、132、145、155、156、166、171、175、176、185、186
*/
$cu = "/^1(30|31|32|45|55|56|66|71|75|76|85|86)\d{8}$/";

/**
* 中国移动:China Mobile
* 134(0-8)、135、136、137、138、139、147、150、151、152、157、158、159、178、182、183、184、187、188、198
*/
$cm = "/^1(34[0-8]|(3[5-9]|47|5[012789]|78|8[23478]|98)[0-9])\d{7}$/";

/**
* 其他号段
* 14号段以前为上网卡专属号段,如中国联通的是145,中国移动的是147等等。
*/
$co = "/^14\d{9}$/";

/**
* 虚拟运营商
* 电信:1700、1701、1702
* 移动:1703、1705、1706
* 联通:1704、1707、1708、1709、171
*/
$cx = "/^1(700|701|702|703|705|706|66|704|707|708|709)\d{7}$/";

/**
* 卫星通信:1349
*/
$cw = "/^1349\d{7}$/";

if (preg_match($cm, $value)) {
return true;
} else if (preg_match($cu, $value)) {
return true;
} else if (preg_match($ct, $value)) {
return true;
} else if (preg_match($co, $value)) {
return true;
} else if (preg_match($cx, $value)) {
return true;
} else if (preg_match($cw, $value)) {
return true;
}
return false;
}
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇PHP面试题 下一篇php单例模式

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目