Операторы


Операторы инкремента и декремента

Оператор Знак Синтаксис Дополнительная информация
Increment ++ $var++ Returns $var, then increments $var by one
++$var Increments $var by one, then returns $var
Decrement -- $var-- Returns $var, then decrements $var by one
--$var Decrements $var by one, then returns $var
<?php
    $var = 3;

    echo $var++;       // echo $var, then increments $var by one
    echo $var;

    echo ++$var;       // increments $var by one, then echo $var
    echo $var;

    echo $var--;       // echo $var, then decrements $var by one
    echo $var;

    echo --$var;       // decrements $var by one, then echo $var
    echo $var;
?>