In this tutorial, we are going to see how to validate an email address in PHP. Validating an email address is an action required before submitting the form. It checks if the user has provided a valid email address. Here is the easiest and most effective way to validate an email address in PHP.
filter_var() function in PHP provides a simple way to validate emails. Use FILTER_VALIDATE_EMAIL filter to validate the email address in PHP. filter_var() function returns the filtered data on success, or FALSE on failure.
How to Validate an Email Address in PHP
<?php
$email = "example@abcd.com";// Email Validation
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
echo "Email address is valid";
}else{
echo "Email address is not valid";
}
?>Output
Email address is valid