note 32504 deleted from control-structures by didou
| From: | didou@php.net | Date: | Thu, 29 May 2003 17:25:00 +0000 |
| Subject: | note 32504 deleted from control-structures by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-49258@lists.php.net to get a copy of this message | ||
Note Submitter: John
----
In response to Armond:
I believe (meaning I haven't tested :-) that the reason this happens is that ($b || $c) is a
boolean test. ie-the computer sees this as: is $b or $c true?
As many (most?) languages see any non-zero value as a boolean TRUE, your statement:
if ($a == ($b || $c))
becomes the equivilant of:
if (TRUE == (TRUE || TRUE))
which will always return true. This is why, if you are trying to compare a single value against two
separate values (/variables/functions/etc.) you must use the syntax:
if ($a == $b || $a == $c)
to work correctly. Then (in the given example) you will say:
(is $a equal to $b) or (is $a equal to $c) ?
which returns FALSE.
Again, I'm not positive, but I believe this might be what's happening.
(A good test might be to set $b and $c = 0, then run your test. If what I believe is true, then the
test should return FALSE.)