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 trialAlec Jones
5,510 PointsMy Code Doesnt Work
I cant seem to get this code to work. Can someone please show me what I did wrong!
<?php
$flavor="choco";
echo "Your favorite flavor of ice cream is ";
echo $flavor;
echo ".";
echo "Randy's favorite flavor is cookie dough, also!";
?>
2 Answers
Andrew Kiernan
26,892 PointsHi Alec!
I'm not sure which step of the challenge is tripping you up, but I assume its the step with the conditional? If that's the case, you want to wrap the final echo statement in an "if" statement. It will look like this:
if ($flavor == "cookie dough") {
echo "Randy's favorite flavor is cookie dough, also!"
};
John Breiner
6,918 PointsAndrew is on the right part for the conditional, I thought I'd show you a cleaner way to do the code for the other statement.
echo "Your favorite flavor of ice cream is " . $flavor . ".";