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

While Loops in PHP Forum

View Course » View Exercise

566 points
051c3f0c48342496eb58043421130ef8?s=140&d=retro
Submitted by
esraaelkady
almost 2 years ago

6/7 keep getiing error . WHY?

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

3 votes

permalink

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

459 points
8f1b02bef3c84590ba490e584e2866ca?s=140&d=retro
Submitted by
ANUJ509
almost 2 years ago

1 Comment

051c3f0c48342496eb58043421130ef8?s=140&d=retro esraaelkady almost 2 years ago

god bless you :)


0 votes

permalink

you need to add $i=0 before and close it with }while( $i>0);

319 points
549c550995e378139300d3c5_545506616
Submitted by
Decode007_5498731276b8fe010a007add_d
almost 2 years ago

2 Comments

549c550995e378139300d3c5_545506616 Decode007_5498731276b8fe010a007add_d almost 2 years ago

also make sure all indentions are in order.

051c3f0c48342496eb58043421130ef8?s=140&d=retro esraaelkady almost 2 years ago

it worked when i replaced while ($loopCond == true); with while ($loopCond);
for a whole day i couldn't think this might be an error