ID:               28760
 Updated by:       [EMAIL PROTECTED]
 Reported By:      james at gogo dot co dot nz
-Status:           Bogus
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: Linux
 PHP Version:      4.3.4
 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.




Previous Comments:
------------------------------------------------------------------------

[2004-07-05 10:40:07] [EMAIL PROTECTED]

Actually, taking another look at this, although I think you'd have to
be unbelievably literal-minded to take the wrong interpretation that's
been taken here, the manual is, perhaps, a little less exact than it
could be.

The sentence at the top of the operator-precedence table that reads:

"The following table lists the precedence of operators with the
highest-precedence operators listed first."

could just be interpreted so that the single entry for "+ - ." is taken
to mean that "+" is of higher precedence than "-" is of higher
precedence than ".".  The problem word here is "before" -- perhaps it
should read "above" (or something similar).  Also, there's no reference
here to what the "Associativity" column might be about.  So, all in all,
perhaps this sentence should be expanded slightly to something like:

"The following table lists the precedence of operators with the
highest-precedence operators listed at the top of the table.  Operators
on the same line have equal precedence, in which case their
associativity decides which order to evaluate them in."

Cheers!

Mike

------------------------------------------------------------------------

[2004-06-13 14:59:50] [EMAIL PROTECTED]

This is not a documentation problem at all, please don't close it as
that.

------------------------------------------------------------------------

[2004-06-13 04:52:54] [EMAIL PROTECTED]

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.

the output should really be:
-5
5

if operator precedence is equal, left to right associativity is used.
To obtain preferred precendence use ().


------------------------------------------------------------------------

[2004-06-13 01:37:28] james at gogo dot co dot nz

Description:
------------
In http://www.php.net/manual/en/language.operators.php the relative
precedence of + - and . is listed as '+ - .'  indicating that + and -
operations should happen before . operations.  

However the code here shows that concatenation happens first.

Personally I would prefer that concatenation happened last as in the
docs as it would be much more sensible (you hardly ever want to use + -
on a result of a concatenation, but often want to use the result of a +
- in a concatenation), but that's obviously too big a change now.

Reproduce code:
---------------
echo 'Foo' . 5 - 5;
echo "\n";
echo 'Foo' . 5 + 5;

Expected result:
----------------
I expect to get the following
---
Foo0
Foo10
---
(+ and - happen first, then concatenation, as according to
documentation)

Actual result:
--------------
The result you get is
---
0
5
---
(. happens first, then the resulting string is evaluated as int
producing 0 which is combined with the next operator and value to
produce the result).



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28760&edit=1

Reply via email to