note 16297 added to ref.var
| From: | php at dynamicink dot com | Date: | Wed, 24 Oct 2001 04:00:26 +0000 |
| Subject: | note 16297 added to ref.var | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19358@lists.php.net to get a copy of this message | ||
The definitions above are pretty poor:
empty -- Determine whether a variable is set
isset -- Determine whether a variable is set
The actual definitions are:
empty - returns true if the variable has been declared AND HOLDS A NULL VALUE.
isset - returns true if the variable has been declared, regardless of it's value. This can be
done many ways for instance: by setting a value (PHP is a loosly typed language afterall,) defining
it as a session variable or appending it to the query string.
example:
if (isset($mom)) {
echo "\$mom has been declared a variable";
if (empty($mom)) {
echo "\mom does not hold any value though";
}
}
If you did not check with isset before using empty and the variable was not declared (!isset) you
would get a 'mom is undefined' error when you call the empty function (unless you used
error supression.)
--
http://www.php.net/manual/en/ref.var.php
http://master.php.net/manage/user-notes.php?action=edit+16297
http://master.php.net/manage/user-notes.php?action=delete+16297
http://master.php.net/manage/user-notes.php?action=reject+16297