开发者

PHP - Email Validation [duplicate]

This question already has answers here: Closed 12 years ago.

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜