Home  >  Article  >  Backend Development  >  php filter_var filters specified data_PHP tutorial

php filter_var filters specified data_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:00:32964browse

Definition and usage
The filter_var() function filters a variable specifying the filter.

Returns success of filtering data or FALSE on failure.

Grammar

filter_var(variable, filter, options)


variable: required. Specify variable filter: optional. Specifies the numbered filter to use. The default is FILTER_SANITIZE_STRING.

Check PHP filters for full possible reference filters. The filter number can be a number name (such as FILTER_VALIDATE_EMAIL) or an ID number (such as 274). Options: Optional. Specifies an associative array of flags/options or a single flag/option. Check out the various possible choices and flags for each filter

Let’s take a look at the filter_var example tutorial

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

Output results.

E-mail is not valid

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445515.htmlTechArticleDefinition and Usage The filter_var() function filters the filter specified by a variable. Returns success of filtering data or FALSE on failure. Syntax filter_var(variable, filter, opti...
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