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 trialCharles Wilmott
1,055 PointsWhy is this code wrong?
<?php
$flavor = "cookie dough";
echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>";
?> <p>Randy's favorite flavor is <?php if ($flavor == "cookie dough") { echo "cookie dough"; }?> , also!</p>
2 Answers
Robert Newman
29,571 PointsI am assuming you are on Challenge Task 1? I don't know if you copied your code over wrong but you have too many php tags in your code.
The below code is what you are after.
<?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!";
?>
If you compare the 2 codes you will be able to see where you have gone wrong with some syntax. You were close :)
Charles Wilmott
1,055 PointsThank you for your great help! :)
Yorick Toma
742 PointsYorick Toma
742 PointsI think they want you to concatenate the string like so :
BUT i didnt even read the assignment, short on time ;)