Change language

PHP filter_has_var () function

|
Syntax:
bool filter_has_var ($type, $variable_name)
Parameters: This function takes two parameters as above and described below:
  • type:This is a required parameter used to specify the type of input to validate. Possible input types: INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, INPUT_ENV.
  • variable_name:is a required parameter used to specify the name of the variable to be checked.
Return value:returns True on success or False on failure.Note.This function is available for PHP 5.2.0 and later.Example 1:In this example, the input variable "name" is sent to a PHP page.
// PHP illustration program
// filter_has_var ( ) if (! filter_has_var (INPUT_GET, " name " )) { echo ( "Input type does not exist" ); } else { echo ( "Input type exists" ); }  
?>
Output: inthis example may not show "Input type exists" as output in the online IDE, as there is no option to send a parameter with a code. So run it somewhere on your server or localhost. If the input type of the name is defined and sent through the GET method, then so! Filter_has_var (INPUT_GET, "name") returns false and prints as "Input type exists". Example 2: < ? php if (! filter_has_var (INPUT_GET, " email " )) { echo ( " Email not found " ); } else { echo ( "Email found" ); }
?>
Output: inthis example the expected results will not appear in the online IDE as they do not allow PHP code to run with GET parameters. So, run it on another hosting server or localhost. Since the email input type is defined and sent by the GET method, then! Filter_has_var (INPUT_GET, "email") returns false and prints the output as "Email found". Links: http://php.net/manual/en/function.filter-has-var.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