In prior version of PHP you had to use some regex solution to validate an email address, now in PHP5 it’s as simple as:
function isValidEmail($email){
return filter_var(filter_var($email, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL);
}
if(isValidEmail(‘email@domain.com’)){
//valid
} else {
//not valid
}
I’ve been using PHP5 ever since it was released but didn’t look into the PECL Filter extension until recently. Pretty handy.
Please note that I [...]