PHP-电子邮件验证 [英] PHP - Email Validation

查看:101
本文介绍了PHP-电子邮件验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

电子邮件地址验证

您好。
我具有此功能来验证电子邮件地址

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);
}

它与 .com 之类的域名区域效果很好, .us 等,其中点后包含2到3个符号。我的问题是:包括长度超过3个符号的 .info .travel 这样的区域是否很重要,我是否应该担心多个 .co.uk 等?如何改善这些需求的功能?

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?

推荐答案

php中有一个本机函数可以执行此操作,对其进行测试并查看是否它满足您的需求:

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));

PS:不是 eregi()不推荐使用?

P.S: Isn't eregi() deprecated?

这篇关于PHP-电子邮件验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆