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

While Loops in PHP Forum

View Course » View Exercise

1175 points
A5ba1285e8142aa3740cc08378e41d6c?s=140&d=retro
Submitted by
Reianna-Bryant
about 2 years ago

Why is my output so strange?

This is my code for the final "do/while loop" lesson:
$spareChange = true;
do {
echo "We need to check that we have enough bus fare.";
while ($spareChange);
echo "We should be fine to go out today.";

It is a simple code, so there is nothing challenging about it. It passes the lesson just fine, but for some reason I get in the output box this:
"Parse error: syntax error, unexpected $end on line 18"

My code does not even have an 18th line! Can someone explain what this is about?


0 votes

permalink

Because you haven't closed the curly braces in you code.

$spareChange = true;
do {
echo "We need to check that we have enough bus fare.";}
while ($spareChange); echo
"We should be fine to go out today.";

125 points
91ea0d13f213ee15d29e8f24b295420f?s=140&d=retro
Submitted by
Mubeen001
about 2 years ago

1 Comment

A5ba1285e8142aa3740cc08378e41d6c?s=140&d=retro Reianna-Bryant about 2 years ago

Okay, thank you. o_O