[PHP-BUG] Doc #81511 [NEW]: Evaluation order for . operator should be specified

[email protected] ("dean at omnivisiontechnology dot com")
Newsgroups php.doc.bugs
Message-ID <[email protected]>
From:             dean at omnivisiontechnology dot com
Operating system: n/a
PHP version:      Irrelevant
Package:          Unknown/Other Function
Bug Type:         Documentation Problem
Bug description:Evaluation order for . operator should be specified

Description:
------------
---
From manual page: https://php.net/language.operators.string
---

In general, PHP doesn't specify the order of evaluation for operators.
However, order of evaluation for the string concatenation operator
specifically,  does always seem to be left then right.

If this can indeed be guaranteed, then it should be specified in the
documentation, because it enables the very common coding idiom:

$string = 'something'.($complicatedSubstring = 'something else').'more
stuff'.$complicatedSubstring;

Test script:
---------------
$s = '[Very bad!]'
$x = 'bar '.($s = 'foo').' bar bar '.$s.' bar';

 

Expected result:
----------------
$x should be 'bar foo bar bar foo bar'.
It'd be very unexpected for it to be 'bar foo bar bar [Very bad!] bar',
But that's what could happen if the . operator evaluated the RHS
first... which fortunately it doesn't appear to.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=81511&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81511&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81511&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81511&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81511&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81511&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81511&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81511&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81511&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81511&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81511&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81511&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81511&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81511&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81511&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81511&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81511&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81511&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.