Here’s the absolute easiest way you can validate an email address using PHP. This tiny function takes advantage of the filter_var() function in PHP.

That said, you really don’t even need the function wrapper if you can remember filter_var() and the appropriate constant.

Just remember that the return value will be the filtered string or false — not always a boolean value like the function above.

To use it:

Finally, no more crazy regular expressions in your code!

Leave a Reply

Your email address will not be published. Required fields are marked *