Does PHP's filter_var FILTER_VALIDATE_EMAIL actually work?

前端 未结 4 2067
一个人的身影
一个人的身影 2020-11-27 16:23

After reading various posts I decided not to use REGEX to check if an email is valid and simply use PHP\'s inbuilt filter_var function. It seemed to work ok, until it starte

4条回答
  •  我在风中等你
    2020-11-27 17:00

    The regular expression used in the PHP 5.3.3 filter code is based on Michael Rushton's blog about Email Address Validation. It does seem to work for the case you mention.

    You could also check out some of the options in Comparing E-mail Address Validating Regular Expressions (the regexp currently used in PHP is one of those tested).

    Then you could choose a regexp you like better, and use it in a call to preg_match().

    Or else you could take the regexp and replace the one in file PHP/ext/filter/logical_filter.c, function php_filter_validate_email(), and rebuild PHP.

提交回复
热议问题