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

challenge task 4 of 4

change the value in the flavor variable to cookie dough.preview the code and make the message appears

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

?>

2 Answers

Sjors Theuns
Sjors Theuns
6,091 Points

Hi Madava,

I'm not sure what it is exactly that you want to know, but for the challenge you need something like:

<?php
$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>";

?>

Above code is for challenge 3 of 4. When you change

$flavor = "strawberry";

into

$flavor = "cookie dough";

You can pass challenge 4 of 4.

Hopefully this makes it a bit clearer, but if you have any question let me know. For future questions please provide a bit more info.

hi sjors

i did as you told me but it is reporting that: " it seems that challenge 2 is no longer visible"and i am struck on challenge since yesterday

Sjors Theuns
Sjors Theuns
6,091 Points

Hi Madava,

I can redo this challenge over and over, without getting the message you are referring to. Perhaps it's better to contact support for this issue. It doesn't look like a programming error on which I can help.

Iain Diamond
Iain Diamond
29,379 Points
<?php
$flavor="Cheese";
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>";
}
?>

Change the value in the flavor variable to cookie dough

The challenge is to change $flavor so that the if condition becomes true, like this:

<?php
$flavor="cookie dough";
...

Hope this help :) iain