Doc #65087 [ReO->Csd]: There is a confusing comment in example
| From: | cmb@php.net | Date: | Fri, 14 Aug 2020 08:54:21 +0000 |
| Subject: | Doc #65087 [ReO->Csd]: There is a confusing comment in example | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17784@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65087&edit=1
ID: 65087
Updated by: cmb@php.net
Reported by: truenrush at gmail dot com
Summary: There is a confusing comment in example
-Status: Re-Opened
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Any
PHP Version: 5.5.0
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Fixed with <http://svn.php.net/viewvc?view=revision&revision=331484>.
Previous Comments:
------------------------------------------------------------------------
[2013-07-20 05:39:29] aharvey@php.net
Reopening, since the commit was reverted and it's being discussed on Internals.
------------------------------------------------------------------------
[2013-07-20 03:39:05] yohgaki@php.net
Fixed wrong documentation.
Doc will be updated in a few days.
Thank you.
------------------------------------------------------------------------
[2013-07-20 01:13:22] yohgaki@php.net
Checking if doc is true or not.
------------------------------------------------------------------------
[2013-06-21 15:02:01] truenrush at gmail dot com
Description:
------------
I would like to report about "Example #1 Associativity" on the following docs
page, because it is very confusing:
http://www.php.net/manual/en/language.operators.precedence.php
1. According to operators precedence table, "++" operator precedence is MUCH MORE
higher then "+" one. As i understand, exactly pre-increment, because post-
increment is always executed last one (table with precedence order is not correct,
eh? do we need to separate pre-increments and post-increments there?)
2. According to http://www.php.net/manual/en/language.operators.increment.php
page, there should be following scenario for your example:
- $a variable is pre-incremented (becomes $a = 2)
- sum is calculated for $a + $a variables (4 number will be printed by echo)
- $a variable is post-incremented (becomes $a = 3)
Test script:
---------------
// mixing ++ and + produces undefined behavior - WTF? result should always be 4
$a = 1;
echo ++$a + $a++; // may print 4 or 5
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65087&edit=1