Jump to content

What Is The Difference Between $I++ And $I+=1


Recommended Posts

<?phpfor($i=0;$i<=10;$i++){$a=$i;echo $a."<br>";}echo $i?>

i got output as


1) question 1) why am i getting 11 after

echo $i

this outside for loop;question 2) I got the same out put when I write


so is can $i++ replace Si+=1 and viceversa

Edited by shad
  • Like 1
Link to comment
Share on other sites

1) when $i is 10 it got incrementd by $i++ so it become 11 and after tha it check the c0nditi0n $i<=10 and it returns false so it come out of lo0p. But at that time $i is still 11 so when you echo it outside of l0op it shows u 112) $i++ and i+=1 is same

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...