Increment / Decrement Operators in PHP ?

Increment and Decrement Operators are common in many Languages,

Increment Operator is represented by ++
Decrement Operator is represented by --

Pre-increment or Pre-decrement:

if you Put increment or Decrement Operator before the variable, operation is done to the variable first then the result is returned.

Post-increment or Post-decrement:

if you put increment or decrement operator after the variable, Operation is done after the variable returned.

Short Description:
++$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.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
DMCA.com Protection Status
0
Would love your thoughts, please comment.x
()
x