php中的post增量和pre increment简单方程

I have this equation:

<?php
$i=5;
$i += $i++ + ++$i;
echo $i;

It gives output 19. Which strange to me as I am new in php. According to my effort I see how it deal.

first ++$i = 5 + 1 = 6 then

$i++ = 6 then

$i + = 6 + 1 = 7 and in total its,

$i += $i++ + ++ $i equals to 7+6+6=19.

can any one tell the how $i += 6 + 1 = 7

Sorry for my bad english. Thanks in advance.

$i=5; 
$i += $i++ + ++$i;  => $i = 5($i++) + 7(++$i) +7($i); echo $i(19);

    =>$i += $i++  +  ++$i;
    => 7  = 5 +7 ;

first it run from right side .first i value will remain 5 then is post increment and becomes 6 and when you add ++$i it will become 7 due to pre increment. and at the last i value will be added which already becomes 7

$i=5;
$i += $i++ + ++$i;  => $i = $i(7(because of $i++ increment)) + ($i++(6) + ++$i(6))
echo $i(19);

Hope this explains it.

The working of that code is undefined. From the docs:

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
?>

Among other things, it is undefined if the right or the left side of the + operator is evaluated first. Hence, the exact outcome of your code is also undefined.