首页 > 代码库 > php验证手机号
php验证手机号
1.实现代码如下
/** * 验证手机号 * @param [type] $tel [description] * @return [type] [description] */ function validatePhoneno($tel){ //正则表达式 if(strlen($tel) == "11"){ //上面部分判断长度是不是11位 $n = preg_match_all("/13[123569]{1}\d{8}|15[1235689]\d{8}|188\d{8}/", $tel,$array); /*接下来的正则表达式("/131,132,133,135,136,139开头随后跟着任意的8为数字 ‘| ‘(或者的意思) * 151,152,153,156,158.159开头的跟着任意的8为数字 * 或者是188开头的再跟着任意的8为数字,匹配其中的任意一组就通过了 * /")*/ if (empty($array)) { return false; } return true; }else{ return false; } }
本文出自 “素颜” 博客,请务必保留此出处http://suyanzhu.blog.51cto.com/8050189/1939080
php验证手机号
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。