Having trouble with the PHP Side Panel


#1

Hi there folks:

I'm having trouble with the side pannel, it keeps loading when I'm done with the exercise.

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

This is the code I made:

<!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

The variable is set to false on purpose, so the loop only executes one iteration. We would never write == false.

while ($loopCond);

That's it. Since the variable is set to false the loop will terminate. If it was set to true and the loop body made no change, it would be an infinite loop. Take care when writing loops. Do some logic review is you are not comfortable with basic logic and control flow.


#3

Then please reset the exercise for me, it is impossible now to get out of the loop since the wrong code was saved.


#4

Make the window small enough for the preview window to disappear, then click Reset or fix the loop code and enlarge the window again. (Alternatively, zoom up for same effect.)


#5

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