Loop Problems Please help!


#1


https://www.codecademy.com/courses/web-beginner-en-5YvPF/0/6?curriculum_id=5124ef4c78d510dd89003eb8#


Its supposed to run the loop once and then stop but that is not happening!

And im just so lost on what I am to do Plz help me.

Replace this line with your code. 
<!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 == false  )
		
		
		echo "<p>Now the loop is done running.</p>";
    ?>
    </body>
</html>


#2

@coder50 change your $loopCond to true to terminate the loop.

$loopCond = true;
do
echo "

The loop ran even though the loop condition is false.

"
while ($loopCond == false );

#3

Maybe, but doubtful. The OP is an infinite loop.

It's important to note the general intent of this lesson, which is to understand how do..while works. The condition is not tested until after the code has run at least once. Since the control is already set to false we need only the conditional,

while ($loopCond)

#4

@netjumper81800(Your code has an error on line 15 it says. :/) This hole lesson honestly makes no sense to me so basicly all the code needs to run once but then why does this code ever have a use if you only want it to run once?? 2nd I'm just so lost on what its trying to teach me. Iv read the lesson several times and can not understand a thing. I'm just Completely lost here.

And i tried to what you guys said and i got this and it prints out 11?!?
Im so lost any help would be great

<!DOCTYPE html>
<html>
    <head>
		<title>Much a do-while</title>
	</head>
	<body>
    <?php
		$loopCond = true;
		do {
			echo ($loopCond);
		}
		while ($loopCond == false);
		echo ($loopCond);
    ?>
    </body>
</html>

#5

Not equal to false, but to true, hence,

   $loopCond = false;
    do {
        echo $loopCond;    // false
    }
    while ($loopcond);
    echo $loopCond;        // false