Email validation using regular expression in PHP

后端 未结 11 1549
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 01:38

I am pretty much new with regular expression. I am developing a project in PHP and i need to validate email address. After searching in this site and google i found the fol

11条回答
  •  情书的邮戳
    2020-11-30 02:24

    I got here looking for a solution and the answer presented by Wayne Whitty do the job, indeed.

    BTW, I think it is good to mention that filter_var function is not RFC5321 compliant. Altought the docs does not say it is, some RFC5321 valid email address will be flagged as invalid by this function, like:

    • localpart.ending.with.dot.@example.com
    • (comment)localpart@example.com
    • "this is v@lid!"@example.com
    • "much.more unusual"@example.com
    • postbox@com
    • admin@mailserver1
    • "()<>[]:,;@\"\!#$%&'*+-/=?^_`{}| ~.a"@example.org
    • " "@example.org

    As presented by this comment http://php.net/manual/pt_BR/function.filter-var.php#112492

提交回复
热议问题