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 trialBaur Alzhanov
7,028 PointsError. I can't check my work.
<?php $flavor = "ice", "cream", "rock road"; if ($flavor == "ice"){ } else if ($flavor == "cream"){ } echo $flavor; echo "<p>Your favorite flavor of ice cream is "; echo "vanilla"; echo ".</p>"; echo "<p>Hal's favorite flavor is cookie dough, also!</p>";
?> final exercise. first I don't understood what I need to do. Second Work couldn't cheek my work.
<?php
$flavor = "ice", "cream", "rock road";
if ($flavor == "ice"){
} else if ($flavor == "cream"){
}
echo $flavor;
echo "<p>Your favorite flavor of ice cream is ";
echo "vanilla";
echo ".</p>";
echo "<p>Hal's favorite flavor is cookie dough, also!</p>";
?>
2 Answers
Gianmarco Mazzoran
22,076 PointsHi Baur,
it's me again! In the final stage of this challenge you need to compare the value inside your flavor variable with this value "cookie dough". This time you are very close:
- you have only to put the if statement after the closing p tag and pass in the last echo statement.
- since you have a string variable is not possible to pass multiple values separate with a colon. If you want to store multiple variable you need an array but it's not this case.
So if the two flavor match, it would be print "Hal's favorite flavor is cookie dough, also!" else anything would be printed!
<?php
$flavor = "cream";
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
if ($flavor == "cookie dough") {
echo "<p>Hal's favorite flavor is cookie dough, also!</p>";
}
?>
Hope it helps to understand the "if" statement!
Baur Alzhanov
7,028 PointsThanks a lot, Gianmarco! I understood my snag.
Gianmarco Mazzoran
22,076 PointsThis is the important Baur! Happy coding! :)