The "All On Your Own" Exercise


#1


The last exercise - exercise 7, A.K.A "All On Your Own."


I think the code is correct but each time I click the submit button it doesn't move me to the next exercise. A gear appears and that's it. Please help.


<!DOCTYPE html>
<html>
    <head>
		<title>Your own do-while</title>
        <link type='text/css' rel='stylesheet' href='style.css'/>
	</head>
	<body>
    <?php
        //write your do-while loop below
        $number = 99;
        do
        {
            echo $number;
        }
        while (66 == 77);
    ?>
    </body>
</html>


#2

Ok, I just tried this same code and it worked for me, but I honestly can't figure out why. When i click submit "99" appears.

Doesn't this code mean echo $number while 66 is equal to 77?? Because since 66 is never equal to 77 I would have thought 99 would not appear?

On a side note, I get the feeling most people have problems with this PHP course because of the environment it's taught in. The platform seems really buggy...


#3

A do..while loop runs at least once, so the output is expected. The false condition terminates the loop. This is as expected.

The exercise may have timed out. Copy your code and refresh the page. Paste back in and try to submit, again.


#4

Ok, thank you.

So if I set while ($number == 99); would that create an infinite loop in this situation?


#5

Absolutely correct. A situation to definitely avoid. Be sure to check loop code carefully.

This unit has an auto-refresh that can easily get ahead of our typing. To disable this so we can type at leisure, add this line of code above your working PHP,

<?php else ?>

Remove when ready to submit (Cut and Paste in next lesson).


#6

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