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 trialUnsubscribed User
1,241 PointsCant do 2/4
<?php
$flavor = vanilla;
echo "<p>Your favorite flavor of ice cream is "; <br /> echo $flavor; echo ".</p>"; echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
My code is wrong somehow :(
3 Answers
Andres Altuve
16,274 PointsModify the command that displays the flavor of ice cream. Instead of it displaying a static piece of text, change it to display the value stored in the 'flavor' variable.
<?php
$flavor ="";
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
Shane Meikle
13,188 PointsSince you are not using the markdown to display the coding properly, it is hard to read it laid out as it is. Here is what I used to pass it:
<?php
$flavor = vanilla;
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>
FYI, if you are interested, clicking the markdown cheatsheet (found below the reply box) can show you how to post the code properly.
Shawn Gregory
Courses Plus Student 40,672 PointsHello,
I think we overlooked the variable declaration in Peter's code. He is declaring the variable $flavor by assigning it a string. When you assign a string to anything in PHP you must surround it with quotes: either single quotes or double quotes. How Peter and Shane has their code, it would produce a syntax error. Add the quotes around vanilla and the code should pass.
Cheers!
Shane Meikle
13,188 PointsGood catch, although interestingly enough, the code challenge doesn't catch that error and still passes it without the quotation marks.