php validating email – How to Validate an Email Address in PHP?

php validating email Checking presence of @ and . and Using filter in PHP & The filter_var() function accepts 3 parameters. Example with US characters only and Example with Unicode characters. and Use the filter_var() Function and the FILTER_VALIDATE_EMAIL and Use the preg_match() Function Examples.

php validating email – How to check the format of an email address in PHP?

Use FILTER_VALIDATE_EMAIL filter to validate the email address in PHP. OR Email Validation in PHP Regular Expression

Validate Email in PHP


Example 2: validation in PHP

 $email_address = "[email protected]";

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email_address)){ 

echo "
Invalid email
"; }else{ echo "
Valid Email
"; }

Also Read : How To Check Email Already Exist In Database In Php?

Example with US characters only

$email_address = '[email protected]';
if(filter_var($email_address, FILTER_VALIDATE_EMAIL)) {
  echo 'Valid!';
} else {
  echo 'Not valid :(';

Example with Unicode characters

$email_address = 'Потапов';
if(filter_var($email_address, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE)) {
  echo 'Valid!';
} else {
  echo 'Not valid :(';

I hope you get an idea about php validating email.
I would like to have feedback on my
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment