Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Creating the Menu and Footer Variables and Conditionals

Confused

I am currently on the final exercise of this code challenge and its prompting me to "Change the value in the flavor variable to cookie dough. Preview the code and make sure the message appears." I tried looking over the video again to find a solution, but no luck so any idea?

3 Answers

Axel Will
Axel Will
4,022 Points

The variable $flavor should go on CODELINE 2

here´s mine with "strawberry" as my favorite and the checkup if it´s also "cookie dough" after i changed my favorite to cookie dough on LINE 2 it executes the echo command.

Change the condition to == "cookie dough" before you change the variable itself to "cookie dough".

BEFORE:

$flavor = "Strawberry";

echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
if ($flavor == "cookie dough"){
  echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
}
?>

AFTER:

$flavor = "cookie dough";

echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
if ($flavor == "cookie dough"){
  echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
}
?>

Hey ya this is how it looks, and it is fine to section 4 but then when i change the $flavor "cookie dough" it give me an error states that I should add a condition to hide this message,

Keith Monaghan
Keith Monaghan
9,494 Points

Which part are you stuck on? It sounds like there is a variable similar to this:

$flavor = "vanilla";

which they want changed to this:

$flavor = "cookie dough";

Does that help?

currently the code looks like this,

<?php

echo "<p>Your favorite flavor of ice cream is "; $flavor = "Vanilla"; echo $flavor; echo ".</p>"; if ($flavor == "Vanilla") {echo "Randy's favorite flavor is cookie dough, also!";};

?>

when i change the $flavor to cookie dough it then redirects me to task 3 as ive no longer completed that.