Change language

PHP Filter_input () function

| |
Syntax:
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:
    • INPUT_GET
    • INPUT_POST
    • INPUT_COOKIE
    • INPUT_SERVER
    • INPUT_ENV
  • $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" ); } }  
?>
Output:
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. " ;  
?>
Output:
Search for tic tac & amp; toc. Search again. 
Links: http://php.net /manual/en/function.filter-input.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () 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