From:             james at gogo dot co dot nz
Operating system: Linux
PHP version:      4.3.4
PHP Bug Type:     Documentation problem
Bug description:  Precedence of + - . incorrect in docs.

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 bug report at http://bugs.php.net/?id=28760&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28760&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28760&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28760&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28760&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28760&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28760&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28760&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28760&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28760&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28760&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28760&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28760&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28760&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28760&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28760&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28760&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28760&r=float

Reply via email to