php – 为什么filter_var($email,FILTER_VALIDATE_EMAIL)允许test @ test?

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 为什么filter_var($email,FILTER_VALIDATE_EMAIL)允许test @ test?脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我只是设置一个表单的验证,我决定尝试使用filter_VAR函数来检查我的邮件地址的有效性.我无法找到什么filter_var实际允许的地方(因为文档很简单),我发现它允许一个电子邮件地址,如test @ test.在域中不必有.COM,.net等…
这个行为在四月份左右发生了变化.见 bug #49576revision 297350.

那个电子邮件确实是无效的,至少这是PHP开发人员所理解的.来提供此通知

/*
 * The regex below is based on a regex by Michael Rushton.
 * However,IT is not identical.  I changed it to only consider routeable
 * addresses as valid.  Michael's regex considers a@b a valid address
 * which conflicts with section 2.3.5 of Rfc 5321 which states that:
 *
 *   Only resolvable,fully-qualified domain names (FQDNs) are PErmitted
 *   when domain names are used in SMTP.  In other words,names that can
 *   be resolved to MX RRs or address (i.e.,A or AAAA) RRs (as discussed
 *   in Section 5) are permitted,as are CNAME RRs whose targets can be
 *   resolved,in turn,to MX or address RRs.  Local nicknames or
 *   unqualified names MUST NOT be used.

changelog提到了这个针对PHP 5.3.3和PHP 5.2.14的错误修复.

脚本宝典总结

以上是脚本宝典为你收集整理的php – 为什么filter_var($email,FILTER_VALIDATE_EMAIL)允许test @ test?全部内容,希望文章能够帮你解决php – 为什么filter_var($email,FILTER_VALIDATE_EMAIL)允许test @ test?所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。