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 trialPHP Variables and Conditionals code challenge
Hi i wonder if someone could help me here? Im stuck on the last question of the code challenge. On Variables and Conditionals and i have absolutely no idea what to do. Everything i try seems to be wrong it driving me mad.
the question is:
Change the value in the flavor variable to cookie dough. Preview the code and make sure the message appears. Your code from each task should be added to the code written in the previous task.
my code:
<?php $flavor = "vanilla"; echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; $flavor = "cookie dough"; if ($flavor == "cookie dough") echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
6 Answers
Figured it out guys i only needed the one $flavor =""; Variable dont no why i thought i needed two lol i wont be making that mistake again XD
Nick Pettit
Treehouse TeacherHey Robbie,
Glad you were able to resolve this. :) It looks like you're having fun with coding though, which is great. Writing code can be difficult at times, but patience and a sense of humor helps!
Jonathan Patton
633 PointsI am stuck on the final part of the quiz, I have changed the variables to cookie dough and it still tells me that I am wrong. I have been going back and forth here and its driving me nuts.
<?php $flavor = "cookie dough"; echo "<p>Your favorite flavor of ice cream is "; if ($flavor == "cookie dough"){ echo "cookie dough"; } if ($flavor == "vanilla"){ echo "off"; } echo ".</p>";
$flavor = "cookie dough"; echo "<p>Randy's favorite flavor is also "; if ($flavor =="cookie dough"){ echo "cookie dough"; } if ($flavor == "vanilla"){ echo "off"; } echo "!</p>"; ?>
Jonathan Patton
633 PointsNever mind I figured it out and I saw what went wrong.
Sebastian Wilson
15,710 PointsI keep on getting an issue with the final task, my issue is that it tells me "Oops! It looks like Task 3 is no longer passing." When I change the value of $flavor
TASK 4
<?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>";
}
?>
TASK 3 Passes
<?php
$flavor = "Bacon";
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>";
}
?>
Sebastian Wilson
15,710 PointsSorted it out