Home > php教程 > php手册 > body text

php filter_var 过滤指定数据

WBOY
Release: 2016-06-13 11:16:49
Original
1187 people have browsed it

 

定义和用法
该filter_var ( )函数的过滤器与一个变量指定的过滤器。

返回过滤数据的成功或FALSE的失败。

语法

filter_var(variable, filter, options)
Copy after login
Copy after login

variable:必需。指定变量过滤 filter:可选。指定编号的过滤器来使用。默认是FILTER_SANITIZE_STRING 。

检查PHP的过滤器完全可能的参考过滤器 过滤器编号可以是一个编号名称(如FILTER_VALIDATE_EMAIL )或身份证号码(如274 )   options:可选。指定一个关联数组的旗帜/选项或一个单一的旗帜/选项。检查每个过滤器的各种可能的选择和旗帜

 

来看看filter_var实例教程

 

 if(!filter_var("someone@example....com", FILTER_VALIDATE_EMAIL))  {  echo("E-mail is not valid");  } else  {  echo("E-mail is valid");  } ?>

 

输出结果.

E-mail is not valid
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!