note 18770 added to function.empty
| From: | scott at php2 dot chek dot com | Date: | Mon, 04 Feb 2002 23:56:27 +0000 |
| Subject: | note 18770 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26250@lists.php.net to get a copy of this message | ||
if you are wanting to know if a string is set and is not null, you would be best to use strlen()
instead of empty() to avoid the typemorph nonsense (in particular, "0" == false) while
still preserving efficiency and logical presentation, i.e.:
if (strlen($string)) {
echo "string was set to ".$string;
} else {
echo "string was not set";
}
--
http://www.php.net/manual/en/function.empty.php
http://master.php.net/manage/user-notes.php?action=edit+18770
http://master.php.net/manage/user-notes.php?action=delete+18770
http://master.php.net/manage/user-notes.php?action=reject+18770