This forum is now read-only. Please use our new forums! Go to forums

0 points
almost 9 years

6/7 - Oops, try again. Did you put parentheses around $LoopCond?

I am getting the right answer for this problem but it will not let me move on to next page since it is error Oops, try again. Did you put parentheses around $LoopCond? <?php $loopCond = false; do { echo “

The loop ran even though the loop condition is false.

“; } while ($loopCond == true);

    echo "<p>Now the loop is done running.</p>";
?>

Answer 553ca0979113cb4c1f000660

1 vote

Permalink

change “while ($loopCond == true);” to “while($loopCond);”

points
Submitted by Bowen619
almost 9 years

3 comments

George Safta almost 9 years

Why? Dosen’t $loopCond have to be true to stop the loop? I mean, it works and all but I don’t get it why.

George Safta almost 9 years

Ok, so I gave a little thinking and I came up with this: The code will echo “The loop ran even though the loop condition is false.” until it hits $loopCond top be true. By having while($loopCond) it means $loopCond is equal to $loopCond which results a true action so “

Now the loop is done running.

“ will be echoed.

George Safta almost 9 years

But, if you change the $loopCond to a value, for ex. 3, it will stop working. I still don’t get it. Can you explain, pls?

Answer 5536bead51b887bb5000019d

0 votes

Permalink

you need the

brackets around “The loop ran even though the loop condition is false.”

points
Submitted by William Elsik
almost 9 years