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 trialFatni Anass
Courses Plus Student 304 PointsHelp
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
21,956 PointsYour 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 . ".";
} ?>
Adam Moore
21,956 PointsYour variable looks like it has a "." in it, and I think it is just supposed to be $flavor = "cookie dough"
, not $flavor = "cookie dough."
Fatni Anass
Courses Plus Student 304 Pointsoh 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
21,956 PointsThe 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>";
}
?>
Fatni Anass
Courses Plus Student 304 PointsThank you so mush Adam it's work :D
Fatni Anass
Courses Plus Student 304 PointsFatni Anass
Courses Plus Student 304 PointsChallenge 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.