note 55969 added to language.expressions
| From: | stochnagara at hotmail dot com | Date: | Fri, 19 Aug 2005 12:06:39 +0000 |
| Subject: | note 55969 added to language.expressions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93892@lists.php.net to get a copy of this message | ||
12345alex at gmx dot net 's case is actually handled by the === operator. That's what he
needs.
There is also another widely used function. I call it myself is_nil which is true for
NULL,FALSE,array() and '', but not for 0 and "0".
function is_nil ($value) {
return !$value && $value !== 0 && $value !== '0';
}
Another useful function is "get first argument if it is not empty or get second argument
otherwise". The code is:
function def ($value, $defaultValue) {
return is_nil ($value) ? $defaultValue : $value;
}
----
Manual Page -- http://www.php.net/manual/en/language.expressions.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55969
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55969&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55969&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55969&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55969&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55969&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55969&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55969&report=yes
Search -- http://master.php.net/manage/user-notes.php