Easy email validation with PHP
Posted by elg3ne on 1 Sep 2009 7:37 pm. Filed under Scipts & Tutorials.
Just found this very simple & efficient way of validating email address with PHP.
You can use this to replace the usual regular expression email checking.
<?php
$email = "john@doe.com";
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Please check your email address";
} else {
echo "Great! valid email address";
}
?>
$email = "john@doe.com";
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Please check your email address";
} else {
echo "Great! valid email address";
}
?>
Source:
http://www.php.net/filter_var