php正则验证邮箱的函数
时间:2021-07-01 10:21:17
帮助过:2人阅读
- function isemail($email) {
- return strlen($email) > 8 && preg_match("/^[-_+.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+([a-z]{2,4})|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email);
- }
- if(!isemail($_POST['email'])) {
- echo "对不起,验证邮箱地址不正确!";
- exit();
- }
- ?>
|