PHP filter_has_var() Function

❮ PHP Filter Reference

Example

Check if the input variable "email" is sent to the PHP page, through the "get" method:

<?php
if (!filter_has_var(INPUT_GET, "email")) {
    echo("Email not found");
} else {
    echo("Email found");
}
?>
Try it Yourself »

Definition and Usage

The filter_has_var() function checks whether a variable of a specified input type exist.

This function checks the content received by the PHP page, so the variable must be sent to the page via e.g a querystring.


Syntax

filter_has_var(type, variable)

Parameter Values

Parameter Description
type Required. The input type to check for. Can be one of the following:
  • INPUT_GET
  • INPUT_POST
  • INPUT_COOKIE
  • INPUT_SERVER
  • INPUT_ENV
variable Required. The variable name to check


Technical Details

Return Value:  TRUE on success, FALSE on failure
PHP Version: 5.2+

❮ Complete PHP Filter Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.