Jump to content

while loop


AV1611

Recommended Posts

Is this valid syntax, or do I need to add "DO {"

[code]

while ($i <= 998)
        {
                 // Do some stuff here
        }


// or do I do this


while ($i <= 998)
        {
            do{
                        //Do some stuff here
                        }
        }

// Or are they identical??????????????
[/code]

Link to comment
https://forums.phpfreaks.com/topic/11871-while-loop/
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/11871-while-loop/#findComment-45100
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.