#40820 [Opn->Csd]: Operator Pecedence
| From: | vrana@php.net | Date: | Fri, 23 Mar 2007 14:10:47 +0000 |
| Subject: | #40820 [Opn->Csd]: Operator Pecedence | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969375827@lists.php.net to get a copy of this message | ||
ID: 40820
Updated by: vrana@php.net
Reported By: mturner at cc dot umanitoba dot ca
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: linux
PHP Version: Irrelevant
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
"Although = has a lower precedence than most other operators, ..."
Previous Comments:
------------------------------------------------------------------------
[2007-03-15 12:57:29] mturner at cc dot umanitoba dot ca
Description:
------------
According to the operator precdence docs, the modulus operator has
precedence over the equals operator. But that is not in fact how it
works, as a recent thread on the php general list has shown.
Reproduce code:
---------------
$s= 5;
$d = 2;
$result = ($s % $d=3);
echo "3 incorrectly assigned to \$d: \$d=$d\n";
echo "result of mod = $result\n"; //$result here is 2: 5 % 3
Expected result:
----------------
This should give an error, instead it assigns 3 to $d and gives a
result of 2.
A parallel bug was reported with respect to the ! and the = operators
in bug #17180, which resulted in a statement at the end of the operator
precedence document which allows for an exception to the rule. Either
the operator precedence rules should be respected or a general inquiry
should be made into how php handles = and a general statement about it
should be appended to the operator precedence docs.
These exceptions to the operator precedence rules are not allowd in
Perl.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40820&edit=1