Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

filter_has_var()

Example

Verify if the “email” input variable is sent to the PHP page using the “get” method.

<?php
if (!filter_has_var(INPUT_GET, “email”)) {
    echo(“Email not found”);
else {
    echo(“Email found”);
}
?>

Definition and Usage

The filter_has_var() function determines if a variable of a specified input type exists.

It checks the content received by the PHP page, meaning the variable must be sent to the page, such as through a query string.

Syntax

filter_has_var(type, variable)

Parameter Values

 

Parameter

Description

type

Required. Specifies the input type to check for, which can be one of the following:

·         INPUT_GET

·         INPUT_POST

·         INPUT_COOKIE

·         INPUT_SERVER

·         INPUT_ENV

variable

Required. Specifies the name of the variable to check.

Technical Details

Return Value:

 Returns TRUE if successful, FALSE if not.

PHP Version:

5.2+