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

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically