这个例子解释了关于POSTFIX和PREFIX的一切。
Operator Name Description
++$x Pre-increment Increments $x by one, then returns $x
$x++ Post-increment Returns $x, then increments $x by one
--$x Pre-decrement Decrements $x by one, then returns $x
$x-- Post-decrement Returns $x, then decrements $x by one
实施例: -
<?php
echo "<h3>Postincrement</h3>";
$a = 5;
echo "Should be 5: " . $a++ . "<br />\n";
echo "Should be 6: " . $a . "<br />\n";
echo "<h3>Preincrement</h3>";
$a = 5;
echo "Should be 6: " . ++$a . "<br />\n";
echo "Should be 6: " . $a . "<br />\n";
echo "<h3>Postdecrement</h3>";
$a = 5;
echo "Should be 5: " . $a-- . "<br />\n";
echo "Should be 4: " . $a . "<br />\n";
echo "<h3>Predecrement</h3>";
$a = 5;
echo "Should be 4: " . --$a . "<br />\n";
echo "Should be 4: " . $a . "<br />\n";
?>
检查此link为更详细地: -
算被用来对变量和值执行操作。
PHP划分运营商在以下组:
-Arithmetic运营
-Assignment运营
-comparison运营
-Increment /递减运营
- 逻辑运算符
个
-STRING运营商
- 阵列运营商
检查这个link为PHP运营商
'++ i' $预和'$ I ++'为岗位,所以是的,你是正确的 – aron9forever
尽管我觉得有必要指出PHP从来没有真正被编译过***,但它被***解释为***,就像python或java字节码 – aron9forever
[PHP文档参考](http://www.php .net/manual/en/language.operators.increment.php)....如果有疑问,请阅读PHP文档 –