AV1611 Posted June 13, 2006 Share Posted June 13, 2006 Is this valid syntax, or do I need to add "DO {"[code]while ($i <= 998) { // Do some stuff here }// or do I do thiswhile ($i <= 998) { do{ //Do some stuff here } }// Or are they identical??????????????[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11871-while-loop/ Share on other sites More sharing options...
trq Posted June 13, 2006 Share Posted June 13, 2006 Your first attempt is valid. Quote Link to comment https://forums.phpfreaks.com/topic/11871-while-loop/#findComment-45048 Share on other sites More sharing options...
AV1611 Posted June 13, 2006 Author Share Posted June 13, 2006 Please disreguard my question, I was obviously out of my mind when I asked that... FOCUS, man, FOCUS!LOL Quote Link to comment https://forums.phpfreaks.com/topic/11871-while-loop/#findComment-45065 Share on other sites More sharing options...
wildteen88 Posted June 13, 2006 Share Posted June 13, 2006 There is two type of while loop do-while loop and while loop they are same apart from do-while is like this:[code]do {}while($i <= 998);[/code]I prefer to use just while whithout the do bit. Quote Link to comment https://forums.phpfreaks.com/topic/11871-while-loop/#findComment-45073 Share on other sites More sharing options...
trq Posted June 13, 2006 Share Posted June 13, 2006 Esentually a [i]while[/i] loop is different from a [i]do while[/i].With a while() your expression is evaluated before each iteration of the loop, do while evaluates the expressions after each iteration. Quote Link to comment https://forums.phpfreaks.com/topic/11871-while-loop/#findComment-45078 Share on other sites More sharing options...
AV1611 Posted June 13, 2006 Author Share Posted June 13, 2006 Thanks you... that mean the while exit is determined by the clause, and the do is determined by some other criteria...that is very usefull information... I always wondered if there was a difference...Thank[!--quoteo(post=383325:date=Jun 13 2006, 11:42 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 13 2006, 11:42 AM) [snapback]383325[/snapback][/div][div class=\'quotemain\'][!--quotec--]Esentually a [i]while[/i] loop is different from a [i]do while[/i].With a while() your expression is evaluated before each iteration of the loop, do while evaluates the expressions after each iteration.[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/11871-while-loop/#findComment-45100 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.