开发者

PHP - Email Validation [duplicate]

开发者 https://www.devze.com 2023-02-09 05:40 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: email address validation
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

精彩评论

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