Ad Code

How to Validate Email in PHP


How to Validate Email in PHP

You can validate Email in PHP by this following function and check the code snippet.The function is FILTER_VALIDATE_EMAIL which is lie in FILTER_VAR having 2 parameters first one is the email you can directly write as (!filter_var("someone@exa mple.com",FILTER_VALIDATE_EMAIL))
but you better check that yourself and then comment back.
<?php
$email = "someone@exa mple.com";

if(!filter_var($email, FILTER_VALIDATE_EMAIL))
  {
  echo "E-mail is not valid";
  }
else
  {
  echo "E-mail is valid";
  }
?>

This will return E-mail is not Valid.
Reactions

Post a Comment

0 Comments