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!
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
Kari Jones
6,217 PointsCode Challenge Help!
I got to this step on the last Code Challenge for Creating the Menu and Footer in Build a Simple PHP Application. I know I have two other forum posts about code challenges, but that just shows how bad I am at this. Here is my code:
<?php
$flavor = "Coffee";
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
<?php if ($flavor == "cookie dough") { echo "<p>Randy's favorite flavor is cookie dough, also!</p>"; } ?>
?>
Please Help!
5 Answers

Chase Lee
29,275 PointsI don't know what code challenge you're on but if I'm right your conditional should have the variable $flavor
and check if it is Randy's flavor.
Hope that helps.

Chase Lee
29,275 PointsIt looks like you have too many closing PHP tags.

Kari Jones
6,217 PointsWhere?

Chase Lee
29,275 PointsOh never mind that but you should take you opening and closing PHP tags on the sixth line.

Waqar Mohammad
iOS Development Techdegree Student 9,914 Points<?php $flavor = "Coffee"; 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>"; } ?>
This should work - you had an opening php tag just before the 'if' statement which wasn't required.

Kari Jones
6,217 PointsThank you! That fixed it!
Kari Jones
6,217 PointsKari Jones
6,217 PointsI am on the last code challenge in Creating the Menu and Footer badge, inside of Build a Simple PHP Application in the Programming course from the library. I posted the wrong code at the end there. Here is what I actually have: