利用简单的正则做的电话号码的验证 无 ?php//用来验证手机号码function checkMobil($string=''){ $pattern = "/^[1]\d{10}$/"; if(preg_match($pattern, $string)){ return TRUE; }else{ return FALSE; }} $mobil = '13510066807';$result = checkMobil($mobi
利用简单的正则做的电话号码的验证
<?php //用来验证手机号码 function checkMobil($string=''){ $pattern = "/^[1]\d{10}$/"; if(preg_match($pattern, $string)){ return TRUE; }else{ return FALSE; } } $mobil = '13510066807'; $result = checkMobil($mobil); var_dump($result);//TRUE; //用来验证座机号码 function checkPhone($string=''){ $pattern = "/^(\d{3,4}-)\d{7,8}$/"; if(preg_match($pattern, $string)) return TRUE; else return FALSE; } $phone = '0755-6661027'; $result = checkPhone($phone); var_dump($result);//TRUE; //用来验证电子邮箱号码 function checkEmail($string=''){ $pattern="/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i"; if(preg_match($pattern, $string)) return TRUE; else return FALSE; } $email = 'asdfasdf23@gmail.com'; $resutl = checkEmail($email); var_dump($result);//TRUE;