Join Up!
104886 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previousis_stringprint_rnext
Last updated: Tue, 28 May 2002
view the printer friendly version or the printer friendly version with notes or change language to Czech | German | Spanish

isset

(unknown)

isset -- Determine whether a variable is set

Description

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

Huomaa: 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().

User Contributed Notes
isset
add a note about notes
There are no user contributed notes for this page.
previousis_stringprint_rnext
Last updated: Tue, 28 May 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST