Email validation using regular expression in PHP

后端 未结 11 1524
爱一瞬间的悲伤
爱一瞬间的悲伤 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:20

    You should use the function filter_vars() to validate your input instead of your own regexp.

    Example:

    filter_var('bob@example.com', FILTER_VALIDATE_EMAIL)
    

    More info in the documentation : http://php.net/manual/en/function.filter-var.php

提交回复
热议问题