note 99588 added to function.trim
| From: | KnutKohl at osu1 dot php dot net | Date: | Wed, 25 Aug 2010 12:59:25 +0000 |
| Subject: | note 99588 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172045@lists.php.net to get a copy of this message | ||
Please consider the following:
$a = '0';
if (trim($a)) {
echo 'Never ever ...';
} else {
echo 'YES, "(bool)trim(\'0\')" is FALSE';
}
So never forget to use:
if (trim($a) != '') ...
This cast costs me some time...
----
Server IP: 217.160.235.204
Probable Submitter: 62.154.196.97
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- https://master.php.net/note/edit/99588
Del: integrated -- https://master.php.net/note/delete/99588/integrated
Del: useless -- https://master.php.net/note/delete/99588/useless
Del: bad code -- https://master.php.net/note/delete/99588/bad+code
Del: spam -- https://master.php.net/note/delete/99588/spam
Del: non-english -- https://master.php.net/note/delete/99588/non-english
Del: in docs -- https://master.php.net/note/delete/99588/in+docs
Del: other reasons-- https://master.php.net/note/delete/99588
Reject -- https://master.php.net/note/reject/99588
Search -- https://master.php.net/manage/user-notes.php