PHP supports C-style pre- and post-increment and decrement operators.
Таблица 10-5. Increment/decrement Operators
Example | Name | Effect |
---|---|---|
++$a | Pre-increment | Increments $a by one, then returns $a. |
$a++ | Post-increment | Returns $a, then increments $a by one. |
--$a | Pre-decrement | Decrements $a by one, then returns $a. |
$a-- | Post-decrement | Returns $a, then decrements $a by one. |
Here's a simple example script:
<?php |
PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in Perl 'Z'+1 turns into 'AA', while in C 'Z'+1 turns into '[' ( ord('Z') == 90, ord('[') == 91 ). Note that character variables can be incremented but not decremented.
Пред. | Начало | След. |
Execution Operators | Уровень выше | Logical Operators |
HIVE: All information for read only. Please respect copyright! |