PHP FILTER_VALIDATE_EMAIL 过滤器

定义和用法

FILTER_VALIDATE_EMAIL 过滤器把值作为电子邮件地址来验证。

  • Name: "validate_email"
  • ID-number: 274

例子

  1. <?php
  2. $email = "someone@exa mple.com";
  3.  
  4. if(!filter_var($email, FILTER_VALIDATE_EMAIL))
  5. {
  6. echo "E-mail is not valid";
  7. }
  8. else
  9. {
  10. echo "E-mail is valid";
  11. }
  12. ?>

输出:

  1. E-mail is not valid