shad Posted December 24, 2011 Share Posted December 24, 2011 <?phpfor($i=0;$i<=10;$i++){$a=$i;echo $a."<br>";}echo $i?> i got output as 01234567891011 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 $i+=1 so is can $i++ replace Si+=1 and viceversa Link to comment Share on other sites More sharing options...
birbal Posted December 24, 2011 Share Posted December 24, 2011 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 More sharing options...
TheGallery Posted December 24, 2011 Share Posted December 24, 2011 You get values from 0 to 11 because you start your counter to 0 and finish it when it equals 10. There are 11 numbers from 0-10. Link to comment Share on other sites More sharing options...
regicidedelferoz Posted January 4, 2012 Share Posted January 4, 2012 funny question.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.