Home >Backend Development >PHP Tutorial >filter_has_var() function in PHP

filter_has_var() function in PHP

王林
王林forward
2023-08-18 15:49:041343browse

filter_has_var() function is used to check whether a variable of the specified type exists.

Syntax

filter_has_var(type, var)

Parameters

  • #type − There are five input types to check, namely INPUT_GET, INPUT_POST, INPUT_COOKIE , INPUT_SERVER or INPUT_ENV.

  • var − The name of the variable.

Return value

The filter_has_var() function returns true on success and false on failure.

Example

The following is an example to quickly check the input variable "email". This example uses the value of INPUT_GET.

Demo

<?php
   if (!filter_has_var(INPUT_GET, "email")) {
      echo("Email isn&#39;t there!");
   } else {
      echo("Email is there!");
   }
?>

Output

The following is the output result.

Email isn&#39;t there!

The above is the detailed content of filter_has_var() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete