Aug 3, 2014, 11:16 PM
Post #2 of 5
This is perfectly normal. In your second example, when $i reaches 10, it still goes once through the while loop (because, at this point, $i <= 10 is still true.) Then $i is incremented, going to 11 and is printed. It is only then that, going to the while once more that the loop is interrupted because, by now, $i <= 10 is no longer true).
In other words, your result has to do with the order in which the operations are done: first check if $i is <= 10, then increment $i and print it.