Home > Backend Development > PHP Tutorial > php filter_input_array Filter illegal information_PHP tutorial

php filter_input_array Filter illegal information_PHP tutorial

WBOY
Release: 2016-07-20 11:00:23
Original
1656 people have browsed it

Definition and usage
The filter_input_array() function gets multiple filters from external input scripts and filters them.

This feature is useful for filtering large input variables without requiring filter_input(), and more.

This feature can input several sources:

INPUT_GET
INPUT_POST
INPUT_COOKIE
INPUT_ENV
INPUT_SERVER
INPUT_SESSION (not implemented yet)
INPUT_REQUEST (not implemented yet)
Returns an array of filtered data on success, false on failure.

Grammar

filter_input(input_type, args)
Copy after login
Copy after login
Copy after login

input_type:required. Specify the input type. See list of possible types above args: Optional. Arguments that specify a series of filters.

A valid key is a variable name and a valid value is a filter ID or an array specifying filters, flags and selections. This parameter can also be a single filter number, if so, all values ​​in the input array are filtered by the specified filter. The filter number can be a number name (such as FILTER_VALIDATE_EMAIL) or an ID number (such as 274)

Tips and Instructions Tip: Please check PHP filters for full possible reference filters to use this feature.

For example, in this example we use the filter_input_array () function to filter the last three variables.

The variables received are a name, age and e-mail address:

<!--?php$filters = array ( "name" =-->array  (  "filter"=>FILTER_CALLBACK,  "flags"=>FILTER_FORCE_ARRAY,  "options"=>"ucwords"  ), "age" => array  (  "filter"=>FILTER_VALIDATE_INT,  "options"=>array   (   "min_range"=>1,   "max_range"=>120   )  ), "email"=> FILTER_VALIDATE_EMAIL, );print_r(filter_input_array(INPUT_POST, $filters));?>
Copy after login
 
Copy after login
Copy after login
返回值勤.
Copy after login
 
Copy after login
Copy after login
Copy after login
Copy after login
Array ( [name] => Peter [age] => 41 [email] => peter@example.com )
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445510.htmlTechArticleDefinition and Usage The filter_input_array() function gets multiple filters from external input scripts and filters them. This feature is useful for filtering large input variables without requiring filtere...
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