PHP isset() Function

❮ PHP Variable Handling Reference

Example

Check whether a variable is empty. Also check whether the variable is set/declared:

<?php
$a = 0;
// True because $a is set
if (isset($a)) {
  echo "Variable 'a' is set.<br>";
}

$b = null;
// False because $b is NULL
if (isset($b)) {
  echo "Variable 'b' is set.";
}
?>
Try it Yourself »

Definition and Usage

The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL.

This function returns true if the variable exists and is not NULL, otherwise it returns false.

Note: If multiple variables are supplied, then this function will return true only if all of the variables are set.

Tip: A variable can be unset with the unset() function.


Syntax

isset(variable, ....);

Parameter Values

Parameter Description
variable Required. Specifies the variable to check
... Optional. Another variable to check

Technical Details

Return Value: TRUE if variable exists and is not NULL, FALSE otherwise
Return Type: Boolean
PHP Version: 4.0+
PHP Changelog: PHP 5.4: Non-numeric offsets of strings now returns FALSE

❮ PHP Variable Handling Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.