November 13, 2011 in PHP, Programming, Tutorials by admin

If you have ever created a form with HTML you know that validating inputs before being processed is very important. When using PHP there are a few ways in which you can validate whether or not the user inputted text is a valid email address or not.

The absolute easiest way to validate an email address is to use the built in PHP email validation

1
2
3
4
5
6
7
<?php
$email = 'name@emailexample.com';
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "This email address is valid";
}
?>