$x = 5; echo "$x"; echo "<br>"; echo $x+++$x++; echo "<br>"; echo $x;
上面代码的输出不是“5,12,5”吗? PHP 输出“5,11,7”?
为什么?我很困惑。最佳答案
查看评论中的注释
$x = 5;
echo $x . PHP_EOL;
// now x=5
echo ++$x + $x . PHP_EOL;
// left side of the operation makes x=6 then the right side adds x to it, meaning 6+6
echo ++$x . PHP_EOL;
// now x=7
另请检查此 What's the difference between ++$i and $i++ in PHP?
了解有关预增量和后增量的一些想法。
关于PHP方程输出困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33221669/