Page 1 of 1
Public shame on me (do..while)
Posted: Wed Jul 27, 2005 5:18 am
by Chris Corbyn
Hi,
How come I never have come across this before? do..while()
It works in PHP and either:
a) Nobody uses it
b) I've lived a sheltered life
c) It's of no real use
I've only come across it since I just started learning C++.
Code: Select all
<?php
$num = 7;
do
{
echo $num."\n";
} while ($x != 7);
?>
Obviously I'm still learning

Posted: Wed Jul 27, 2005 5:28 am
by anjanesh
do..while has been there for decades.
Even QBasic has it as DO..LOOP WHILE or DO...LOOP UNTIL
C/C++ had do...while since the beginning
PHP's programming structure is very much like C++ and this has been there right from the first version I guess since PHP is the new language.
Many people use this including me.
This is used when you want a loop to take place ateleast once irrespective of the condition.
Posted: Wed Jul 27, 2005 5:47 am
by Chris Corbyn
anjanesh wrote:do..while has been there for decades.
Even QBasic has it as DO..LOOP WHILE or DO...LOOP UNTIL
C/C++ had do...while since the beginning
PHP's programming structure is very much like C++ and this has been there right from the first version I guess since PHP is the new language.
Many people use this including me.
This is used when you want a loop to take place ateleast once irrespective of the condition.
Yeah I know what it does I just never seen it used in PHP LOL..
I'm a n00b (at least Jcart calls me a n00b

)
Posted: Wed Jul 27, 2005 12:58 pm
by pickle
My guess is:
do...while isn't taught (either in the classroom or in books) as much as a plain while loop. So people , when thinking of algorithms, usually don't develop their logic in ways that would utilise a do...while loop.
I've honestly only used it twice in 3 years.
Posted: Wed Jul 27, 2005 1:02 pm
by anjanesh
pickle wrote:
I've honestly only used it twice in 3 years.
Strange - because many times I have come across situaations where I had to loop it atleast once with no regard to condition for the first time.
I thought these situations occur frequently.
Posted: Wed Jul 27, 2005 1:06 pm
by John Cartwright
I have known about it for quite some time, but have never actually used it in any software. Although I've seen it a lot, the time never arises when I truly need it
d11wtq wrote:I'm a n00b (at least Jcart calls me a n00b Razz)
