Home > Backend Development > PHP Tutorial > php filter_var filters specified data_PHP tutorial

php filter_var filters specified data_PHP tutorial

WBOY
Release: 2016-07-20 11:00:32
Original
1057 people have browsed it

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)
Copy after login
Copy after login

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
Copy after login

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...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template