note 45009 added to function.empty
| From: | csst0266 at cs dot uoi dot gr | Date: | Mon, 23 Aug 2004 10:50:01 +0000 |
| Subject: | note 45009 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75156@lists.php.net to get a copy of this message | ||
Be careful when using empty(). It takes a variable as an argument, and not a constant value.
So, empty($var); would be right, while empty(trim($var)); would be wrong. This is because the trim
function returns a constant string value which is passed to empty() as an argument. The second case
could have been trim($var) == ''; instead. It is a common pitfall I have encountered many
times, so watch out. :-)
----
Manual Page -- http://www.php.net/manual/en/function.empty.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45009
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45009&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45009&report=yes
Search -- http://master.php.net/manage/user-notes.php