PHP » Miscellaneous » isset()

Syntax:
bool isset(mixed var [, mixed var, ...])
var
Variable to test.

Returns whether a variable has been set.

The isset() function returns TRUE if a variable has been set with a value. Multiple variables can be tested at the same time. TRUE is returned only if all the variables tested have been set.

Examples

Code:
<?php

$a = "Some data";

if (isset($a)) {
   print "\$a = $a<br>";
}

if (!isset($b)) {
   print "\$b does not exist<br>";
}

if (isset($_REQUEST["c"])) {
   print "c sent via URL.";
} else {
   print "c not available.";
}

print "<br><br><a href=\"isset.php?c=hello\">Link that passes c</a>";

?>
Output:
$a = Some data
$b does not exist
c sent via URL.

Link that passes c
Explanation:

$a has been set with a value and is printed. $b has not been set. c is sent when the user clicks the link.

See Also: