increase understanding.
as you know, you can do
Code:
i understand this: Code:
and i know how it works in the "for" loops. what i dont understand is the way im using it here: Code:
now in the switch, say the variable was greater than three and it was reset to 0. does the switch use the increased variable or does the variable increase after the switch? |
Re: increase understanding.
PHP Code:
|
Re: increase understanding.
well i believe it doesnt increase the variable until after the switch because i have debug msgs and it showed that case 0 would show up, which means it wouldnt increase the 0 to 1. (i didnt debug till after i posted. sryz)
so unless someone else seconds your statement, im all set =] |
Re: increase understanding.
As you have found, djmd378 is mistaken.
var++ - post-increment - returns var, then increments var ++var - pre-increment - increments var, then returns var The difference between the two doesn't make a practical difference if you use them as a single statement - only if you use the return value. |
Re: increase understanding.
i thought i was right, but i didnt know what you just showed me O.o
i thought that variable++ and ++variable were the same but i guess not. tnx lee =D |
Re: increase understanding.
Yep,
i == i ++ but i++ != i (And ++i == i but i != ++i ) If that doesn't just confuse you further |
Re: increase understanding.
i = 1;
i == i ++ first it checks if i == i, wich of corse is true, then it sets i to i+1. i++ != i first it stores the value of i, 1, then it sets i to i+1, and then it checks if 1 == i where i is 2. ++i == i: first i is set to i+1, then it checks if i == i, wich of corse is true. i != ++i becose it first stores 1, then it adds 1 to to i, and then it will check if 1 == 2, which of corse is false. I hope you understand. Everything works as it should work. |
| All times are GMT -4. The time now is 16:12. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.