PHP验证一些信息
最近被迫在搞PHP。。整理些验证信息的代码:
代码
php正则表达式验证用户名大小写+数字)
^[a-zA-Z][\w\d_]{5,19}
验证电话号码
(\d{3}-)(\d{8})$|(\d{4}-)(\d{7})$
php的邮件验证:
< ?
function checkmail($mail){
if(ereg(“^[a-zA-Z0-9_-]+@[a-zA-Z0-9]+\.[a-zA-Z]+$”,$mail)){
return 1;
} else return 0;
}
$m=”yaiba23@163.com”;
echo checkmail($m);
?>
^[a-zA-Z][\w\d_]{5,19}
验证电话号码
(\d{3}-)(\d{8})$|(\d{4}-)(\d{7})$
php的邮件验证:
< ?
function checkmail($mail){
if(ereg(“^[a-zA-Z0-9_-]+@[a-zA-Z0-9]+\.[a-zA-Z]+$”,$mail)){
return 1;
} else return 0;
}
$m=”yaiba23@163.com”;
echo checkmail($m);
?>