PHP | filter_input() Function
The filter_input() is an inbuilt function in PHP which is used to get the specific external variable by name and filter it. This function is used to validate variables from insecure sources, such as user input from form. This function is very much useful to prevent some potential security threat like SQL Injection.
filter_input( $type, $variable_name, $filter, $options)
Parameters: This function accepts four parameters as mentioned above and described below:
- $type: It is mandatory parameter and used to check the type of input. The list of filters are:
- $variable_name: It is required parameter. It is used to hols the name of variable which is to be checked.
- $filter: It is an optional parameter. It holds the name or ID of the filter. If this parameter is not set then FILTER_DEFAULT is used.
- $options: It is an optional parameter and used to specify one or more flags/options to use. It check for possible options and flags in each filter. If filter options are accepted then flags can be provided in “flags” field of array.
Return Value: It returns the value of the variable on success or False on failure. If parameter is not set then return NULL. If the flag FILTER_NULL_ON_FAILURE is used, it returns FALSE if the variable is not set and NULL if the filter fails.
Search for tic tac & toc. Search again.