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 trialJohn O mahoney
578 PointsWhat is wrong with this code ???
???
<?php
$flavor = "Chicken";
echo "<p>Your favorite flavor of ice cream is ";
echo "<?php echo $flavor ?>";
if ($flavor == "cookie dough."){
echo "<p>Hal's favorite flavor is cookie dough, also!</p>";
}
else {
echo ".</p>";
}
?>
1 Answer
Joel Bardsley
31,249 PointsHi John, I've copied your code below and added comments for things that don't look quite right:
<?php
$flavor = "Chicken";
echo "<p>Your favorite flavor of ice cream is ";
echo "<?php echo $flavor ?>"; // No need to use another set of php tags and an echo statement here
if ($flavor == "cookie dough."){ // this requires the user to enter a full stop after cookie dough for this condition to match
echo "<p>Hal's favorite flavor is cookie dough, also!</p>"; // as $flavor equals cookie dough, you can echo the variable instead
}
else {
echo ".</p>"; // no need for an else statement here, if $flavor doesn't equal cookie dough, it can be ignored. But note that if $flavor does equal cookie dough, your code will have two opening <p> tags and one closing </p> tag.
}
?>
If any of the above is unclear, let me know. Good luck.