#28760 [Csd->Bgs]: Precedence of + - . incorrect in docs.
| From: | derick@php.net | Date: | Sun, 13 Jun 2004 12:59:51 +0000 |
| Subject: | #28760 [Csd->Bgs]: Precedence of + - . incorrect in docs. | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969361339@lists.php.net to get a copy of this message | ||
ID: 28760
Updated by: derick@php.net
Reported By: james at gogo dot co dot nz
-Status: Closed
+Status: Bogus
Bug Type: Documentation problem
Operating System: Linux
PHP Version: 4.3.4
New Comment:
This is not a documentation problem at all, please don't close it as
that.
Previous Comments:
------------------------------------------------------------------------
[2004-06-13 04:52:54] curt@php.net
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