isset

bool isset(mixed variable) 

Tests whether a variable is set.

Returns:

TRUE if the variable contains a value other than NULL; FALSE otherwise

Description:

isset() is used to check whether a variable is currently set.

Note:

If the variable contains a null value (NULL), isset() returns FALSE. Note that a null byte ("\0") is not equivalent to the PHP constant NULL. If a variable contains only a null byte ("\0"), it is still considered to be set.

Also note that isset() cannot be used on a literal (such as 10, "A string", and so on)—see the example.

Availability:

UNIX, Windows

Version:

3+, 4+

See also:

empty() 

Example:

Demonstrate how isset() works
 <pre> <?php $greeting = "Hi!"; if (isset ($value)) print "\$greeting is set.\n"; else print ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.