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.
- function is_validemail($email)
- {
- $check = 0;
- if(filter_var($email,FILTER_VALIDATE_EMAIL))
- {
- $check = 1;
- }
- return $check;
- }
Copy code
Usage:
- $email = "blog@open.com";
- $check = is_validemail($email);
- echo $check;
- // If the output is 1, then email is valid.
- ?>
Copy code
|