php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65087 There is a confusing comment in example
Submitted: 2013-06-21 15:02 UTC Modified: 2013-07-20 05:39 UTC
From: truenrush at gmail dot com Assigned:
Status: Re-Opened Package: Documentation problem
PHP Version: 5.5.0 OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: truenrush at gmail dot com
New email:
PHP Version: OS:

 

 [2013-06-21 15:02 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-20 01:13 UTC] yohgaki@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: yohgaki
 [2013-07-20 01:13 UTC] yohgaki@php.net
Checking if doc is true or not.
 [2013-07-20 03:39 UTC] yohgaki@php.net
-Status: Assigned +Status: Closed
 [2013-07-20 03:39 UTC] yohgaki@php.net
Fixed wrong documentation.
Doc will be updated in a few days.
Thank you.
 [2013-07-20 05:39 UTC] aharvey@php.net
-Status: Closed +Status: Re-Opened -Assigned To: yohgaki +Assigned To:
 [2013-07-20 05:39 UTC] aharvey@php.net
Reopening, since the commit was reverted and it's being discussed on Internals.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Sep 23 19:01:26 2018 UTC