➤ 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.
Syntax:
isset(variable, ....); // second parameter is optional, another variable to check
For instance:
$x = 0;
// True because $x is set
if (isset($x)) {
echo "Variable 'x' is set\n";
}
$y = null; // or $y;
// False because $y is NULL
if (isset($y)) {
echo "Variable 'y' is set.";
// Declare an array
$array = array('PHP'=> true);
// Use isset function
echo isset($array['PHP']) ? 'Array is set.' :
'Array is not set.';
// outputs: Array is set.
}