How to Validate Email in PHP

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 "";

// Validate email
"$email is a valid email address";
"$email is not a valid email address";

Leave a reply