PHP - 电子邮件验证
可能的重复:
电子邮件地址验证
您好。 我有这个函数来验证电子邮件地址,
function isValidEmail($email){
return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}
它适用于 .com、.us 等域区域,这些区域在点后包含 2 到 3 个符号。我的问题是:包含 .info 或 .travel 等长度超过 3 个符号的区域是否重要,我是否应该担心多个 .co.uk等等?如何针对这些需求完善功能?
Possible Duplicate:
email address validation
Hello.
I have this function to validate an email address
function isValidEmail($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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
php 中有一个本机函数可以执行此操作,请对其进行测试并查看它是否符合您的需求:
PS:难道
eregi()
已被弃用吗?there is a native function in php to do this, test it and see if it fits your needs:
P.S: Isn't
eregi()
deprecated?