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

filter_has_var() function in PHP

王林
Release: 2023-08-18 15:50:01
forward
1352 people have browsed it

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

Syntax

filter_has_var(type, var)
Copy after login

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!");
   }
?>
Copy after login

Output

The following is the output result.

Email isn&#39;t there!
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template