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 trialMd Asif
246 PointsWhat is the problem with this script, it's asking to echo in $flavor. I do not assume any mistakes but it showing Bummer
The message in the final echo command only makes sense if your favorite flavor is the same as Hal's. Add a conditional around that final echo command that checks if the flavor variable has a value of "cookie dough." (Remember to choose carefully between using a single equal sign and a double equal sign in the check.) Preview the code and, if you have a different flavor, make sure the message disappears.
<?php
$flavor = "Chocolate";
echo "<p>Your favorite flavor of ice cream is ";
echo .$flavor;
echo ".</p>";
if($flavor == "cookie dough") {
echo "<p>Hal's favorite flavor is also cookie dough, also!</p>";
} else {
echo "<p>Too bad Hal doesn't love $flavor like I do!</p>";
}
?>
Md Asif
246 PointsThe problem still persists, as it saying : Bummer! We tried setting $flavor to "cookie dough", but we didn't see the message "Hal's favorite flavor is cookie dough, also!".
<?php
$flavor = "Chocolate";
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo "</p>";
if($flavor == "cookie dough") {
echo "<p>Hal's favorite flavor is also cookie dough, also!</p>";
} else {
echo "<p>Too bad Hal doesn't love $flavor like I do!</p>";
}
?>
Joel Bardsley
31,249 PointsThe problem looks like you've modified the string you're echoing inside the if conditional - there's an extra 'also' in the string:
Hal's favorite flavor is also cookie dough, also!
If removing that doesn't pass the challenge, try removing the else statement as the challenge hasn't specified to include that.
1 Answer
Simon Coates
28,694 PointsI think you changed the output text. It accepts:
<?php
$flavor = "Chocolate"; // task1
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor; //task2.
echo ".</p>";
if($flavor=="cookie dough"){//task3
echo "<p>Hal's favorite flavor is cookie dough, also!</p>"; //removed word here
}
?>
efewafewa
21,825 Pointsefewafewa
21,825 PointsThis is your problem...
Use the . to combine strings within one statement, for example...
which would work. However, if you want to use multiple lines, it would be...