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 trial

PHP Build a Simple PHP Application Creating the Menu and Footer Variables and Conditionals

"Be sure you add a conditional to hide the message"

I'm having a some trouble in this part. Can someone be of any assistance? I would really appreciated.

Stone Preston
Stone Preston
42,016 Points

can you post the code youve tried so far please

Sorry about that I was about to post it but I accidentally left the page that I was working on -_____- let me go ahead and post it here now that I re-done it. (definitely not having a good day).

<?php
$flavor="strawberry";
echo "<p>Your favorite flavor of ice cream is ";
echo "$flavor";
echo ".</p>";
If ($flavor == "cookie dough") 
{echo "Randy's favorite flavor is cookie dough, also!";}
"<p>Randy's favorite flavor is cookie dough, also!</p>";

?>

3 Answers

Stone Preston
Stone Preston
42,016 Points

oh sorry though you were on task 3. it looks like oyu need to change the value of $flavor to cookie dough. you also need to keep the paragraph tags around the string inside the if statement:

<?php
$flavor = "cookie dough";
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
if ($flavor == "cookie dough") {
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";

}

?>
Stone Preston
Stone Preston
42,016 Points

you only want the "randys favorite flavor..." string to appear IF the flavor variable is cookie dough. currently you have it appearing if the flavor is cookie dough, but after the if statement as well which means it will be there no matter what (and it will appear twice if $flavor is cookie dough).

remove the second one so that its only echoed if and only if the flavor is cookie dough

<?php
$flavor="strawberry";
echo "<p>Your favorite flavor of ice cream is ";
echo "$flavor";
echo ".</p>";
If ($flavor == "cookie dough") 
{
echo "Randy's favorite flavor is cookie dough, also!";
}
?>

I did as you told me but unfortunately I keep getting the same message (this is on the 4th task)