note 18325 added to function.empty
| From: | cezeugoh at hotmail dot com | Date: | Fri, 18 Jan 2002 13:02:19 +0000 |
| Subject: | note 18325 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25027@lists.php.net to get a copy of this message | ||
It would appear empty() has to be used in conjunction with isset(). painful experience has taught me
that empty() alone doesnt work as expected with empty strings i.e "".
empty() would return false where the variable is existent and is empty or where the variable is
non-existent also. so you might have to test first with isset() to find out if the variable is
existent then check with empty() to see if it contains an empty string.
An example is as follows:
if (!isset($a)) {
//echo the variable doesnt exist!
}
elseif empty($a) {
// echo it exists but is empty!
}
else {
//echo it exists but and contains something!
}
--
http://www.php.net/manual/en/function.empty.php
http://master.php.net/manage/user-notes.php?action=edit+18325
http://master.php.net/manage/user-notes.php?action=delete+18325
http://master.php.net/manage/user-notes.php?action=reject+18325