How to validate an Email in PHP?

后端 未结 7 839
梦毁少年i
梦毁少年i 2020-11-22 05:20

How can I validate the input value is a valid email address using php5. Now I am using this code

function isValidEmail($email){ 
     $pattern = \"^[_a-z0-9         


        
7条回答
  •  遇见更好的自我
    2020-11-22 05:59

    See the notes at http://www.php.net/manual/en/function.ereg.php:

    Note:
    

    As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice. See the list of differences for help on converting to PCRE.

    Note:
    

    preg_match(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg().

提交回复
热议问题