note 20810 added to language.operators.logical
| From: | destes at ix dot netcom dot com dot nospam | Date: | Wed, 17 Apr 2002 03:26:24 +0000 |
| Subject: | note 20810 added to language.operators.logical | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29458@lists.php.net to get a copy of this message | ||
If you're like me, staring at the definition of the !$var syntax, you might be wondering how
you can use this to test whether a variable exists, or quickly compare its value in a slap-dash
fashion. For instance, my programs use config files where most of the values are stored either as
integers 0 or 1, indicating whether the option is on or off.
After sifting through the documentation, here's the section I found:
http://www.php.net/manual/en/language.types.boolean.php
(scroll to the "Converting to Boolean" header)
For the reasons in that section, this approach will work. Part of it states that:
if ($var) {
...
is the same as stating:
if ($var == true) {
...
And in the same sense, (!$var) is the same as ($var == false). Read the above link for the
specifics.
--
http://www.php.net/manual/en/language.operators.logical.php
http://master.php.net/manage/user-notes.php?action=edit+20810
http://master.php.net/manage/user-notes.php?action=delete+20810
http://master.php.net/manage/user-notes.php?action=reject+20810