Using || and OR, seems like bug...
Posted: Sat May 13, 2006 11:32 am
Hi, I've searched and looked in the PHP.net manual for this problem.
Here is basic example which will echo "TRUE":
$Var = 8;
if ($Var == 2 || 3) {
echo "TRUE";
}
My question is: why is it echoing TRUE when $Var clearly does not equal 2 OR 3.
If I use "OR" instead of "||" it will still echo TRUE.
If a string is used instead of a number, it will still echo TRUE.
If I use the bitwise "|" operator, it works fine (does not display TRUE).
To me, this seems like a bug since 8 is not at all equal to 2 or3. Any thoughts are much appreciated.
Here is basic example which will echo "TRUE":
$Var = 8;
if ($Var == 2 || 3) {
echo "TRUE";
}
My question is: why is it echoing TRUE when $Var clearly does not equal 2 OR 3.
If I use "OR" instead of "||" it will still echo TRUE.
If a string is used instead of a number, it will still echo TRUE.
If I use the bitwise "|" operator, it works fine (does not display TRUE).
To me, this seems like a bug since 8 is not at all equal to 2 or3. Any thoughts are much appreciated.