#45410 [Bgs]: Bad result in an expression evaluation
| From: | ensnnet at gmail dot com | Date: | Mon, 14 Jul 2008 14:41:53 +0000 |
| Subject: | #45410 [Bgs]: Bad result in an expression evaluation | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-126669@lists.php.net to get a copy of this message | ||
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:
Thanks, I was wrong (sorry for my insistence). Assignement (=) is done
before the and/or opperation but the &&/|| opperation is done before the
assignement (=).
Thanks very much for your attention and explanation.
Previous Comments:
------------------------------------------------------------------------
[2008-07-14 11:22:57] mgf@php.net
*Please* look at Example 1 at http://php.net/operators.logical, as
requested by colder - this demonstrates your example exactly and shows
that what you're getting is the expected result. The operator
precedence table at
http://php.net/operators#language.operators.precedence
(also previously
referred to) may also help.
This is *not* a bug, so don't add to this conversation. If you need
further explanation, please ask in the support forums (such as
php-general@lists.php.net).
------------------------------------------------------------------------
[2008-07-11 17:59:03] ensnnet at gmail dot com
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
------------------------------------------------------------------------
[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
------------------------------------------------------------------------
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