Doc #65087 [Opn->Asn]: There is a confusing comment in example

From: Date: Sat, 20 Jul 2013 01:13:22 +0000
Subject: Doc #65087 [Opn->Asn]: There is a confusing comment in example
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10093@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: yohgaki@php.net Reported by: truenrush at gmail dot com Summary: There is a confusing comment in example -Status: Open +Status: Assigned Type: Documentation Problem Package: Documentation problem Operating System: Any PHP Version: 5.5.0 -Assigned To: +Assigned To: yohgaki Block user comment: N Private report: N New Comment: Checking if doc is true or not. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#10093) next »