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

PHP code to verify email address is valid

WBOY
Release: 2016-07-25 08:42:41
Original
1444 people have browsed it

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


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template