Home >Backend Development >PHP Tutorial >PHP code to verify email address is valid

PHP code to verify email address is valid

WBOY
WBOYOriginal
2016-07-25 08:42:411432browse

Sometimes, when filling out a form on a website, the user may enter an incorrect email address. This function can verify whether the email address is valid.

  1. function is_validemail($email)
  2. {
  3. $check = 0;
  4. if(filter_var($email,FILTER_VALIDATE_EMAIL))
  5. {
  6. $check = 1;
  7. }
  8. return $check;
  9. }
Copy code

Usage:
  1. $email = "blog@open.com";
  2. $check = is_validemail($email);
  3. echo $check;
  4. // If the output is 1, then email is valid.
  5. ?>
Copy code

Email address, PHP


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP parses JSON dataNext article:PHP parses JSON data