PHP - Email Validation [duplicate]
Possible Duplicate:
email address validation
Hello. I have this function to validate an email address
function isVa开发者_如何学PythonlidEmail($email){
return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}
It works well with domain zones like .com, .us etc, which contain from 2 to 3 symbols after a dot. My question is: is it important to include such zones as .info or .travel with length more than 3 symbols and should I worry about multiple .co.uk etc.? How to improve the function for these needs?
there is a native function in php to do this, test it and see if it fits your needs:
var_dump(filter_var('bob@example.com', FILTER_VALIDATE_EMAIL));
P.S: Isn't eregi()
deprecated?
精彩评论