Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVijesh Arora
Front End Web Development Techdegree Student 34 PointsPost and Pre Increment in PHP?
<?php
$i = 10;
$a = $i++;
echo $a; // It return original value 10
$i = 10;
$a = ++$i; // It return updated value 11
echo $a;
My question is when to use post and pre increment; I know it is useful for loops, and it increments the value like written in above code, but I am confused whether to use post or pre increment and in which case it most efficient. I also hear that for performance wise, pre-increment is more effective.
MODERATOR EDIT: Added Markdown to the post for code readability. Please refer to the Markdown CheatSheet on how to post code to the Community.