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

Help

Change the value in the flavor variable to cookie dough. Preview the code and make sure the message appears. i dont understant this question ? i make that's code but they sey "" Oops! It looks like Task 3 is no longer passing.""

<?php $flavor = "cookie dough"; echo $flavor; if($flavor == "cookie dough" ){ echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; } ?>

4 Answers

Adam Moore
Adam Moore
21,956 Points

Your code:

<?php $flavor = "cookie dough";
echo $flavor;
if($flavor == "cookie dough" ){
echo "Your favorite flavor of ice cream is "; echo $flavor; echo ".";
 } ?>

May need to use concatenation with . instead of separate semi-colons for the statement to echo in the "if" statement. Like this:

<?php $flavor = "cookie dough";
echo $flavor;
if($flavor == "cookie dough" ){
echo "Your favorite flavor of ice cream is " .  $flavor . ".";
 } ?>

Challenge task 3 of 4 im doing great!

<?php $flavor = "cookie dough."; echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; echo $flavor; if($flavor == "cookie dough."){ echo $flavor; } ?>

Challenge task 4 of 4 Change the value in the flavor variable to cookie dough. Preview the code and make sure the message appears.

Adam Moore
Adam Moore
21,956 Points

Your variable looks like it has a "." in it, and I think it is just supposed to be $flavor = "cookie dough", not $flavor = "cookie dough."

oh yes thank you so much for your answers i try but it not work !! this the code :

<?php $flavor = "cookie dough"; echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; echo $flavor;

if($flavor == "cookie dough"){ echo $flavor; } ?>

Adam Moore
Adam Moore
21,956 Points

The challenge asks for you to put the last statement into a conditional, so that if the variable $flavor is equal to "cookie dough," then it will echo out "Randy's favorite flavor is cookie dough, also!", not simply echo out the variable $flavor. Like this:

<?php

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

Thank you so mush Adam it's work :D