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 trialSyed Mahbub
8,780 PointsMy code is rendering as it should be, but Im still getting an error.
So Task 3 is working fine,but in task 4, im changing the variable and for some reason that is causing "Task 3" to stop working.
Leonardo Hernandez
13,798 Points<?php
$flavor = "Cookie Dough";
echo "Your favorite flavor of ice cream is ";
echo "$flavor";
echo ".";
if ($flavor == "Cookie Dough") {
echo "Randy's favorite flavor is cookie dough, also!";
}
?>
4 Answers
Louis Otto
23,264 Pointscan you please post your code so we can take a look?
Syed Mahbub
8,780 PointsHey Louis, here: <?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>"; } ?>
Louis Otto
23,264 PointsOK you've removed some of the <p> tags which are essential, but otherwise it's perfect. Remember also that it asks you to check what happens when it doesn't match, so change your flavor to chocolate as I've done, and the below will pass. I hope this makes sense:
<?php
$flavor = "chocolate";
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
if ($flavor == "Cookie Dough")
{ echo "Randy's favorite flavor is cookie dough, also!";
} ?>
?>
Leonardo Hernandez
13,798 PointsSorry about the double post, the code I commented above is your code so that anyone trying to help can view it all easily.
I believe task one, two, and three concatenated some <p> tags into the echo commands. If you removed those, that could be your problem. In that case, your code as it functions is not the problem.
Louis Otto
23,264 PointsAlso you wrapped the variable $flavor in quotes, you don't do that for variables, only strings.
Leonardo Hernandez
13,798 PointsLeonardo Hernandez
13,798 Points