Home >php教程 >PHP源码 >php自带函数判断是否email地址

php自带函数判断是否email地址

PHP中文网
PHP中文网Original
2016-05-25 17:12:331048browse

以前我们常用一招用正则判断是不是正确的email地址 
其实php早就想到了. 

用filter_var 这个函数就可以 
var_dump(filter_var('bob.example.com', FILTER_VALIDATE_EMAIL)); 
显示 bool(false)

var_dump(filter_var('bob@example.com', FILTER_VALIDATE_EMAIL));
显示bob@example.com 

PHP代码

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

                   


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn