php验证手机号码和邮箱
发布时间:2022-09-28 22:40:11 361
相关标签: # php
/**
* 验证手机号是否正确
* @author honfei
* @param number $mobile
*/
function isMobile($mobile) {
if (!is_numeric($mobile)) {
return false;
}
return preg_match('#^1[3,4,5,7,8,9]{1}[\d]{9}$#', $mobile) ? true : false;
}
/**
* 正则表达式验证email格式
*
* @param string $str 所要验证的邮箱地址
* @return boolean
*/
function isEmail($str) {
if (!$str) {
return false;
}
return preg_match('#[a-z0-9&\-_.]+@[\w\-_]+([\w\-.]+)?\.[\w\-]+#is', $str) ? true : false;
}
文章来源: https://blog.51cto.com/u_13646572/5361398
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报