Check if a variable of a specified input type exist in PHP

Description

The following code shows how to check if a variable of a specified input type exist.

Example


<?php/*from ww w .j  a v a  2 s . com*/
    if(!filter_has_var(INPUT_GET, "name")){
        echo("Input type does not exist");
    }else{
        echo("Input type exists");
    }

/*    INPUT_GET
      INPUT_POST
      INPUT_COOKIE
      INPUT_SERVER
      INPUT_ENV
*/
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone