PHP validate email addresses

By | 6 February, 2014

To rapidly, and decently, validate email addresses, we can use something like this:

$email = "email@domain.com";

if (filter_var($email, FILTER_VALIDATE_EMAIL)) { 
    echo "This email is valid"; 
} 

The filter_var() returns the filtered data or FALSE if it fails

Read about it, and more filters, here:

function filter_var()