开发者

Which Method For Verification ? REGEX or filter_var?

What do you think, is there any difference (for performance, security, reliability ) between this methods :

METHOD 1

eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)

METHOD 2

filter_var($ema开发者_开发问答il, FILTER_SANITIZE_EMAIL) 
filter_var($email, FILTER_VALIDATE_EMAIL)


Method 2 is clearly easier to understand and more maintainable. The regular expression just looks like line noise.


If method 2 is a good email validation then thats better.

Method 1 could be cleaned up if case insensitive to this (expanded)

Correction: did not read the regex close enough.

Stick with method 2 ..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜