PHP Manual
Prev |  | Next

# isset

(PHP 3, PHP 4 )

isset -- Determine whether a variable is set

## Description

bool isset ( mixed var [, mixed var [, ...]])

> Note: isset() is a language construct.

Returns `TRUE` if `var` exists; `FALSE` otherwise.

If a variable has been unset with unset(), it will no longer be isset(). isset() will return `FALSE` if testing a variable that has been set to `NULL`. Also note that a `NULL` byte (`"\0"`) is not equivalent to the PHP `NULL` constant.

    <?php
        $a = "test";
        $b = "anothertest";

        echo isset ($a); // TRUE
        echo isset ($a, $b); //TRUE

        unset ($a);
        echo isset ($a); // FALSE
        echo isset ($a, $b); //FALSE

    $foo = NULL;
        print isset ($foo); // FALSE
    ?>

This also work for elements in arrays:

    <?php
        $a = array ('test' => 1, 'hello' => null);

        echo isset ($a['test']);  // TRUE
        echo isset ($a['foo']);   // FALSE
        echo isset ($a['hello']); // FALSE
        echo array_key_exists('hello', $a); // TRUE
    ?>

See also empty(), unset(), and array_key_exists().

Prev | Home | Next
is_string | Up | print_r