php正則驗證手機、郵箱

速貸100發表於2017-08-09

//驗證電話
private function reg_phone($phone){
        if (preg_match(“/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/”,$phone){
            return true;
        else{
            return false;
        }
    }
//驗證郵箱
private function check_email($mail){
    if(preg_match(`/^[w-.]+@[w-.]+(.w+)+$/`$mail))
        return true
    }else
        return false
    
}


相關文章