Bummer! You have been redirected as the page you requested could not be found.

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 Basic PHP Website (2018) Building a Media Library in PHP Variables and Conditionals

What 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.

index.php
<?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>";
}

?>

This is your problem...

<?php
  echo .$flavor;

Use the . to combine strings within one statement, for example...

<?php
  "<p>Your favorite flavor of ice cream is " . $flavor . "</p>";

which would work. However, if you want to use multiple lines, it would be...

<?php
  echo "<p>Your favorite flavor of ice cream is ";
  echo $flavor;
  echo "</p>";

The 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
Joel Bardsley
31,249 Points

The 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
Simon Coates
28,694 Points

I 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
}
?>