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 ..
精彩评论