What is the error in do while loop?


#1




Much a do-while


<?php
$loopCond = false;
do {
echo "

The loop condition is false.

";
}
while ($loopCond == true);
	echo "<p>Now the loop is done running.</p>";
?>
</body>

got error:expandFull Screen Save & Submit Code Reset Code Oops, try again. Did you put parentheses around $LoopCond?


#2

Right here, you create the variable. The 'do' block is a semi complete while loop.


#3

what it should be? can you be more specific ?


#4

I don't personally know PHP, didn't take the course, but to me it looks like you were trying to turn the

into a while loop, and if you were then you forgot the whole "while ($loopCond == false);" part


#5

do is not a standalone construct. It is do-while.

keyword {
    // code block
} keyword (condition);

#6

isn't my example like that ?


#7

Not how I remember it. Must be a blown fuse. Belay, belay.


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.