Doc #74329 [Opn]: Inconsistency in operators precedence example
| From: | pierstoval at gmail dot com | Date: | Wed, 29 Mar 2017 08:26:53 +0000 |
| Subject: | Doc #74329 [Opn]: Inconsistency in operators precedence example | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14557@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74329&edit=1
ID: 74329
User updated by: pierstoval at gmail dot com
Reported by: pierstoval at gmail dot com
Summary: Inconsistency in operators precedence example
Status: Open
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
The "may print either 2 or 3" issue only happens with 2 PHP versions:
* PHP 4.3.0 (released in 2002 and fixed 2 months later in 4.3.1)
* and 5.0.5 (released in 2005 and fixed 3 months later in 5.1.0).
That's why I consider this "may print either 2 or 3" sentence as an inconsistency
Previous Comments:
------------------------------------------------------------------------
[2017-03-29 08:15:34] pierstoval at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/language.operators.precedence
---
There's an inconsistency in Example #2 on the "Language Operators Precedence" page.
The example states that the script "may print either 2 or 3", but actually, it will
*always* print "3", and for the second script, the array will *always* be equal "[2
=> 1]".
This might confuse people about the real role of precedence operators.
You can check on 3v4l here: https://3v4l.org/EUknn
Test script:
---------------
// First script
$a = 1;
echo $a + $a++;
echo "\n";
// Second script
$i = 1;
$array[$i] = $i++;
var_export($array);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74329&edit=1