Phpfilter_input function. In php Tutorial 5.2, the built-in filter module is used for variable verification and filtering. For more information about how to filter variables, see what I previously mentioned. here we will take a look at how to directly filter user input. in php Tutorial 5.2, the filter module is built in for variable verification and filtering.
For more information about how to filter variables, see what I previously mentioned. here we will look at how to filter user input directly.
The filter_input function corresponding to the fliter module is very simple to use. for example, if we filter the get parameter named sample as an integer, we can write
Filter_input (input_get, "sample", filter_sanitize_number_int );
Filter_input parameters are user input types, corresponding input names, and filtering (verification) constants. Currently, filter_input supports the following types of user input:
Input_get // corresponding to $ _ get
Input_post // corresponding to $ _ post
Input_cookie // corresponding to $ _ cookie
Input_server // corresponding to $ _ server
Input_env // corresponding to $ _ env
With various built-in verification tokens, you can solve similar user input filtering and other "physical activity" problems ".
Finally, we need to mention the small trap of filter.
Filter_var ('ABC', filter_validate_boolean); // bool (false)
Filter_var ('0', filter_validate_boolean); // bool (false)
The fliter module is mentioned again on php arch, which can save a lot of time.
If the data provided by users such as $ _ get and $ _ post are improperly used, such as incomplete verification and filtering, security problems may occur. In general, we will write a regular expression to verify whether the data format is legal.
The built-in filter module is used for variable verification and filtering in tutorial 5.2. For more information about how to filter variables, see what I previously mentioned. here we will look at how to filter user input directly...