Change language

PHP Filter_input () function

| |
filter_input ($type, $variable_name, $filter, $options) 
Parameters:this the function takes four parameters as above and described below:
  • $type:this is a required parameter used to validate the input type. Filter list:
  • $variable_name:Required. It is used to store the name of the variable to be checked.
  • $filter:This is an optional parameter. It contains the name or ID of the filter. If this parameter is not set, then FILTER_DEFAULT is used.
  • $options:is an optional parameter used to specify one or more flags / options to use. It checks for possible choices and flags in each filter. If the filter parameters are accepted, the flags can be specified in the "flags" field of the array.
Returned value:returns the value of the variable on success, or False on error. If the parameter is not set, return NULL. If the FILTER_NULL_ON_FAILURE flag is used, it returns FALSE if the variable is not set and NULL if the filter fails.Example 1:
// PHP program for checking mail using a filter if (isset ( $_ GET [ "email" ])) { if (! filter_input (INPUT_GET , "email" , FILTER_VALIDATE_EMAIL) === false) { echo ( " Valid Email " ); } else { echo ( "Invalid Email" ); } }  
Valid Email 
Example 2:  
// Input type: INPUT_GET input name: search
// filter name: FILTER_SANITIZE_SPECIAL_CHARS $search_variable_data = filter_input (INPUT_GET , ’search’ , FILTER_SANITIZE_SPECIAL_CHARS );  
// Input type: INPUT_GET input name: search
// filter name: FILTER_SANITIZE_ENCODED $search_url_data = filter_input (INPUT_GET, ’search’ , FILTER_SANITIZE_ENCODED); echo " Search for $search_variable_data. " ; echo " Search again. " ;  
Search for tic tac & amp; toc. Search again. 
Links: /manual/en/function.filter-input.php


Best laptop for Sims 4


Best laptop for Zoom


Best laptop for Minecraft


Best laptop for engineering student


Best laptop for development


Best laptop for Cricut Maker


Best laptop for hacking


Best laptop for Machine Learning


Latest questions


psycopg2: insert multiple rows with one query

12 answers


How to convert Nonetype to int or string?

12 answers


How to specify multiple return types using type-hints

12 answers


Javascript Error: IPython is not defined in JupyterLab

12 answers


Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method