#45410 [Bgs]: Bad result in an expression evaluation
ID: 45410
User updated by: ensnnet at gmail dot com
Reported By: ensnnet at gmail dot com
Status: Bogus
Bug Type: Unknown/Other Function
Operating System: windows xp sp3
PHP Version: 5.2.6
New Comment:
Te answer on my machine for the previous code is:
Here l1 and l2 is: bool(false)
But here l1 and l2 is: bool(true)
And here l2 and l1 is: bool(false)
What happens?
... And I think it must be false in all the three cases !!
Thanks in advance for your attention,
jaz
Previous Comments:
------------------------------------------------------------------------
[2008-07-11 17:55:55] ensnnet at gmail dot com
Sorry by I still I think something is wrong. Please take a while to
see the next code (or run it on your machine):
<?php
$l1 = true;
$l2 = false;
$l1_and_l2 = $l1 and $l2;
$l2_and_l1 = $l2 and $l1;
echo "<pre>";
echo "Here l1 and l2 is: ";
var_dump($l1 and $l2);
echo "But here l1 and l2 is: ";
var_dump($l1_and_l2);
echo "And here l2 and l1 is: ";
var_dump($l2_and_l1);
echo "What happens?";
echo "</pre>";
?>
------------------------------------------------------------------------
[2008-07-02 21:32:31] colder@php.net
Please take a look at the examples on php.net/operators.logical
------------------------------------------------------------------------
[2008-07-02 19:03:39] johannes@php.net
Please see the operator precedence table and explanation on the page I
ahve given, somewhere in the upper area are "&&", "||" and so on, then
"=" and in the bottom "and", "or", "xor" which means the
assignment is
done before the "and" operator is executed. For further questions please
refer to other support forums, see http://php.net/support.php
------------------------------------------------------------------------
[2008-07-02 17:12:16] ensnnet at gmail dot com
Thank for your answer johannes@php.net but still I think someone is not
correct, perhaps I am wrong.
I have read your link:
http://es2.php.net/manual/en/language.operators.logical.php:
And y read there:
$a and $b => TRUE if both $a and $b are TRUE.
I had writed another simple code that dont run as expected (I send you
at the end of this note). The result that show on my computer is:
$l1 = TRUE, $l2 = FALSE => $l1 and $l2 is FALSE
$l1 = TRUE, $l2 = FALSE => $l1 and $l2 is TRUE
$l1 = TRUE, $l2 = FALSE => $l1 and $l2 is FALSE
$l1 = TRUE, $l2 = FALSE => $l1 and $l2 is FALSE
I think the second line must be as the another lines. What is wrong?
Thanks for your attention,
jaz
This is the code:
<?php
$v1 = "A";
$v2 = 0;
$l1 = $v1=="A";
$l2 = $v2!=0;
$flag1 = $l1 and $l2;
$flag2 = ($l1 and $l2);
$flag3 = $l2 and $l1;
echo "\$l1 = ".showAstxt($l1).", \$l2 = ".showAstxt($l2)." => \$l1 and
\$l2 is ".showAstxt($l1 and $l2)."<br>";
echo "\$l1 = ".showAstxt($l1).", \$l2 = ".showAstxt($l2)." => \$l1 and
\$l2 is ".showAstxt($flag1)."<br>";
echo "\$l1 = ".showAstxt($l1).", \$l2 = ".showAstxt($l2)." => \$l1 and
\$l2 is ".showAstxt($flag2)."<br>";
echo "\$l1 = ".showAstxt($l1).", \$l2 = ".showAstxt($l2)." => \$l1 and
\$l2 is ".showAstxt($flag3)."<br>";
// ============================================================
function showAstxt($v)
{
return $v ? "TRUE" : "FALSE";
}
?>
------------------------------------------------------------------------
[2008-07-01 23:08:37] johannes@php.net
sorry wrong URL, correct one: http://php.net/operators
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/45410
--
Edit this bug report at http://bugs.php.net/?id=45410&edit=1
Thread (10 messages)