This forum is now read-only. Please use our new forums at discuss.codecademy.com.

While Loops in PHP Forum

View Course » View Exercise

225 points
531984708c3e1bb7911eb31eeaf2808c?s=140&d=retro
Submitted by
swapnil19
over 2 years ago

Not able to complete while loop tutorial.

<?php
$loopCond = false;
do {
echo "The loop ran even though the loop condition is false.";
} while ($loopCond);
echo "Now the loop is done running.";
?>


0 votes

permalink

You have exactly what I have, and it wouldn't work even though it gives the correct answer. After troubleshooting it for a long time I finally tried it again in Firefox and it let me submit it without any changes. I've been having a lot of instability in chrome, so maybe that's the issue?

246 points
Picture
Submitted by
Brandyn Bakanoff
over 2 years ago

2 Comments

531984708c3e1bb7911eb31eeaf2808c?s=140&d=retro swapnil19 over 2 years ago

thanks for reply, but I am facing this issue in IE,chrome and firefox too... Tried to submit so many times but same error pops up.

Ccc51a1fa4de9531b8517caafd83ef6a?s=140&d=retro Cody Tucker over 2 years ago

I have the same issue. I will try Firefox first though.


0 votes

permalink

I tried it many times and I found out that the condition loopCond is already being set as False, so you have to enclose that variable with while,
My final answer accepted by the terminal is
<!DOCTYPE html>
<html>
<head><title>Much a do-while</title></head>
<body>
<?php
$loopCond = false;
do {
echo "<p>The loop ran even though the loop condition is false.</p>";
} while ($loopCond);
echo "<p>Now the loop is done running.</p>";
?>
</body>
</html>

854 points
566c65c49376760bea0008f0_818544291
Submitted by
Mudit Gupta
over 2 years ago