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

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

PHP中文网
Release: 2016-05-25 17:12:33
Original
1055 people have browsed it

以前我们常用一招用正则判断是不是正确的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)
Copy after login

                   


source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template