天天看點

php正則驗證手機、郵箱

//驗證電話

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(

('/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/', $mail)){ 

        return true; 

    }else{ 

        return false; 

    } 

}