本文介绍了为什么filter_var($ email,FILTER_VALIDATE_EMAIL)允许test @ test?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是对表单进行验证,因此我决定尝试使用filter_var函数来检查我的电子邮件地址的有效性。我无法找到filter_var实际上允许在任何地方使用的内容(因为文档非常简单),并且我发现它允许使用类似test @ test的电子邮件地址。

I was just setting up the validation for a form in which I decided to try using the filter_var function to check the validity of my email address. I can not find out what filter_var actually allows anywhere though (since the documentation is very simple), and I found out that it is allowing an email address like test@test. Doesn't there have to be a .com, .net etc... in the domain?

推荐答案

域中的域是否一定没有.com,.net等...?四月左右的某个地方。请参见和。

The behavior has changed somewhere around April. See bug #49576 and revision 297350.

该电子邮件确实无效,或者至少是PHP开发人员理解的。消息来源带有此通知:

That e-mail is indeed invalid, or at least that's what the PHP developers understood. The source carries this notice:

/*
 * 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.

提到了针对PHP 5.3.3和PHP 5.2.14的错误修复。

The changelog mentions this bug fix for PHP 5.3.3 and PHP 5.2.14.

这篇关于为什么filter_var($ email,FILTER_VALIDATE_EMAIL)允许test @ test?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 16:50