Phpfilter_input function _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.