PHP | filter_has_var() function Last Updated : 14 Feb, 2019 Comments Improve Suggest changes Like Article Like Report The filter_has_var() function is an inbuilt function in PHP which is used to check whether the variable available or not especially it checks if a variable of a specified input type exist or not. It returns True on success or False on failure. Syntax: bool filter_has_var( $type, $variable_name ) Parameters: This function accepts two parameters as mentioned above and described below: type: It is the required parameter and used to specify the type of input to check. The possible input types are INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, INPUT_ENV. variable_name: It is the required parameter and used to specify the name of a variable which need to check. Return Value: It returns True on success or False on failure. Note: This function is available for PHP 5.2.0 and later versions. Example 1: In this example, the input variable "name" is sent to the PHP page. php <?php // PHP program to illustrate // filter_has_var() function if(!filter_has_var(INPUT_GET, "name")) { echo("Input type does not exist"); } else { echo("Input type exists"); } ?> Output: This example may not show "Input type exists" as output in online IDE as there is no option for sending parameter with the code. So run it somewhere on server or localhost. If the name input type defined and sent through GET method so !filter_has_var(INPUT_GET, "name") returning false and printing output as "Input type exists". Example 2: php <?php if (!filter_has_var(INPUT_GET, "email")) { echo("Email not found"); } else { echo("Email found"); } ?> Output: This example will not show expected output in online IDE as they do not allow to run PHP code with GET parameters. So, run it on some other hosting server or in localhost. As email input type defined and sent through GET method so !filter_has_var(INPUT_GET, "email") returning false and printing output as "Email found". References: http://php.net/manual/en/function.filter-has-var.php Comment More infoAdvertise with us Next Article PHP | filter_has_var() function G gekcho Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | filter_list() Function The filter_list() function is an inbuilt function in PHP which is used to returns the list of all supported filters. Syntax: array filter_list( void ) Parameters: This function does not accepts any parameters. Return Values: It returns an array containing all names of supported filters. If it return 2 min read PHP | filter_id() Function The filter_id() function is an inbuilt function in PHP which returns the filter ID of a specified filter name. It is used to get the filter id of the particular filter in PHP by using filter_id function by giving the name of the filter as input and get the associated id to it. Syntax: int filter_id( 2 min read PHP | filter_input() Function The filter_input() is an inbuilt function in PHP which is used to get the specific external variable by name and filter it. This function is used to validate variables from insecure sources, such as user input from form. This function is very much useful to prevent some potential security threat lik 2 min read PHP | stream_get_filters() Function The stream_get_filters() function is an inbuilt function in PHP which is used to get the list of registered stream filters. Syntax: array stream_get_filters( void ) Parameters: This function does not accept any parameter. Return Value: This function returns an array containing the name of all availa 1 min read PHP | var_export() Function The var_export() is a built-in function in PHP which is used to return the structured value(information) of a variable that is passed to this function as a parameter. This function is similar to the var_dump() function.Syntax: var_export($var, $return) Parameters: This function accepts two parameter 1 min read Like