php验证电子邮件扩展类型

时间:2016-09-18 22:47:45

标签: php

这是我验证电子邮件的代码,它运行良好,但我想如果电子邮件不以.mil结尾,则说无效的电子邮件

if (isset($_POST['update_email'])) {

        $email = escape($_POST['email']);

        if (empty($email)) {
            $errors[] = "Email Address Required.";
        }
        if (email_exists($email)) {
            $errors[] = "Email Address in use.";
        }

        if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
            $errors[] = "Invalid Email Address";
        }

        if (! empty($errors)) {

            echo validation_errors($errors[0]);
        } else {

   }

感谢。

1 个答案:

答案 0 :(得分:1)

添加正则表达式条件语句

Link

或许您可以在email_exists中构建此逻辑。

相关问题