Using filter_var to validate email addresses in PHP
As from version 5.2, PHP comes with built-in data filtering. Which makes validating emails and URL very, very easy.
Validating email addresses in PHP
It couldn’t be easier than this, could it?
function valid_email( $str=false ) {
if( !$str ) {
return false;
}
if(filter_var($str, FILTER_VALIDATE_EMAIL)) {
return true;
} else {
return false;
}
}
You can do much more with the new PHP filtering functions, this is all I’ve got time for now.