xxxxxxxxxx
$options = [
'key' => 'value',
'blank' => '',
'nothing' => null,
];
var_dump(isset($options['key']), empty($options['key'])); // true, false
var_dump(isset($options['blank']), empty($options['blank'])); // true, true
var_dump(isset($options['nothing']), empty($options['nothing'])); // false, true
xxxxxxxxxx
// Using isset()
$variable = "";
if (isset($variable)) {
echo "\$variable is set and not null.";
} else {
echo "\$variable is not set or null.";
}
// Using empty()
$variable = "";
if (empty($variable)) {
echo "\$variable is either null, an empty string, 0, or not set.";
} else {
echo "\$variable is not empty.";
}