Memory App
 



Building memory bonds
Php  >     ZCE 5.3  |  Patterns  |  Modern Php Php   >   Operators   >   Aritmetic

Return first

If the operator is placed after its operand, the interpreter will first return the value of the latter (unchanged), and then either increment or decrement it by one.

$a = 1;
echo $a++; // output 1
echo $a; // output 2

$a = 1;
echo ++$a; // output 2
echo $a; // output 2

Incrementing booleans

Incrementing or decrementing booleans has no effect

$a = TRUE;
echo ++$a; // 1
echo $a; // 1

Arithmetics on chars

PHP follows Perl's convention when dealing with arithmetic operations on character variables.

$i = 'W';
for ($n=0; $n<6; $n++) {
    echo ++$i . "n";
}
// output X Y Z AA AB AC