Email validation is a required action before submitting the user input in the server-side. It checks whether the user has provided a valid email address. Here’s the absolute easiest and effective way to validate an email address using PHP.
The filter_var() function in PHP, provides an easy way for email validation. Use FILTER_VALIDATE_EMAIL filter to validate email address in PHP. The filter_var() function returns the filtered data on success, or FALSE on failure.
$email = "email@example.com";
// Validate email
echo "$email is a valid email address";
echo "$email is not a valid email address";