PHP Increment-Decrement Operator With Example

Increment/Decrement Operators:

The PHP increment operators are used to increment a variable's value. The PHP decrement operators are used to decrement a variable's value.

List of Increment/Decrement Operators:

Operator Name Effect
++$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

Example:



Result:

  11
  1110
  119
  910
  9	

Read Also: