Bug #78829 [Nab]: æ°åä¼ å¼ç¨è®¡ç®é®é¢
Edit report at https://bugs.php.net/bug.php?id=78829&edit=1
ID: 78829
Updated by: cmb@php.net
Reported by: 1003674174 at qq dot com
Summary: æ°åä¼ å¼ç¨è®¡ç®é®é¢
Status: Not a bug
Type: Bug
Package: Variables related
Operating System: windows
PHP Version: 7.3.11
Block user comment: N
Private report: N
New Comment:
> It's about the undefined execution order.
I don't think so, since it doesn't matter whether (++$a) is
evaluated before (++$a) or the other way round. It rather
seems to me that PHP < 7 got confused by the reference.
Previous Comments:
------------------------------------------------------------------------
[2019-11-18 15:12:35] requinix@php.net
It's about the undefined execution order.
https://www.php.net/manual/zh/language.operators.precedence.php
> Operator precedence and associativity only determine how expressions are grouped, they do not
> specify an order of
> evaluation. PHP does not (in the general case) specify in which order an expression is
> evaluated and code that
> assumes a specific order of evaluation should be avoided, because the behavior can change
> between versions of PHP
> or depending on the surrounding code.
>
> Example #2 Undefined order of evaluation
<?php
$a = 1;
echo $a + $a++; // may print either 2 or 3
$i = 1;
$array[$i] = $i++; // may set either index 1 or 2
?>
(the page is already marked as needing a translation update)
------------------------------------------------------------------------
[2019-11-18 13:11:13] cmb@php.net
Isn't 5 the output one would expect?
------------------------------------------------------------------------
[2019-11-18 09:35:47] 1003674174 at qq dot com
Description:
------------
php5.6echoç弿¯6ï¼php7ç弿¯5
Test script:
---------------
$a=1;$b=&$a;echo (++$a)+(++$a);exit;
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78829&edit=1
Thread (7 messages)