Php filter_input filter function example tutorial

Source: Internet
Author: User

 

Definition and usage
The input filter of the filter_input () function obtains scripts and filters from external sources.

This function is used to verify the source of insecure variable form, such as user input.

You can enter several sources for this feature:

INPUT_GET
INPUT_POST
INPUT_COOKIE
INPUT_ENV
INPUT_SERVER
INPUT_SESSION (not implemented yet)
INPUT_REQUEST (not implemented yet)
The data filtering is successful. If the false fault or NULL is returned, the parameter "change" is not set.

Syntax

filter_input(input_type, variable, filter, options)
 
Parameter
Description
Input_type Required. Specifies the input type. See the list of possible types above
Variable Required. Variable Filtering
Filter Optional. Specify the number of filters to use. The default value is FILTER_SANITIZE_STRING. Check whether PHP filters are completely possible. Refer to the filters. The filter number can be a serial number name (such as FILTER_VALIDATE_EMAIL) or an ID number (such as 274)
Options Optional. Specify the flag/option of an associated array or a single flag/option. Check various possible options and flags for each filter
Check the instance.
 

For example, in this example, we use the filter_input () function to filter the variable. The variable received is a valid Email address:

 
 
Output is.
 
 
E-Mail is valid

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.