我是php
的新手,由于某种原因,增量/减量反向运行。有人可以告诉我这背后的原因吗?
<?php
$var1 = 3;
echo "Addition = " . ($var1 += 3) . "<br>" ;
echo "Subtraction = " . ($var1 -= 3) . "<br>" ;
echo "Multiplication = " . ($var1 *= 3) . "<br>" ;
echo "Divison = " . ($var1 /= 3) . "<br>" ;
echo "Increment = " . $var1++ ;
echo "Decrement = " . $var1-- ;
?>
答案 0 :(得分:0)
如果你知道增量和减量运算符是如何工作的,你就会得到答案。
<form ... autocomplete="off">
...
</form>
//打印$ var1然后递增值
echo "Increment = " . $var1++ ;
//从先前的操作中打印递增的值,然后递减值
要实现您的目标,请使用echo "Decrement = " . $var1-- ;