php 检查邮箱 和手机号

/**
* 检查手机号码格式
* @param $mobile 手机号码
*/
function check_mobile($mobile){
if(preg_match('/1[34578]\d{9}$/',$mobile))
return true;
return false;
}

/**
* 检查固定电话
* @param $mobile
* @return bool
*/
function check_telephone($mobile){
if(preg_match('/^([0-9]{3,4}-)?[0-9]{7,8}$/',$mobile))
return true;
return false;
}

/**
* 检查邮箱地址格式
* @param $email 邮箱地址
*/
function check_email($email){
if(filter_var($email,FILTER_VALIDATE_EMAIL))
return true;
return false;
}

猜你喜欢

转载自www.cnblogs.com/lsbaiwyl/p/9067632.html
今日推荐