Below, some easy and quite simple examples of increments and decrements!
Post in/decrement:
Those adjustments are following a simple rule… First show the count, then add/substract 1.
Pre in/decrement:
Those adjustments are following a simple rule… First add/substract 1, then show the count.
Increment
// Example 1 (post increment) First show, then add 1 // Start number $count = 0; // Result: 0 echo $count++; // Just to prove the result will be 1 finally.... echo $count; // Example 2 (pre-increment) First add 1, then show // Start number $count = 0; // Result: 1 echo ++$count;
Decrement
// Example 1 (post decrement) First show, then substract 1 // Start number $count = 10; // Result: 10 echo $count--; // Just to prove the result will be 9 finally.... echo $count; // Example 2 (pre-decrement) First substract 1, then show // Start number $count = 10; // Result: 9 echo --$count;
Mail this!
- Comments (0)
- PingBacks (0)
- TrackBacks (0)


» Latest comments