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

Alec Jones
Alec Jones
5,510 Points

My Code Doesnt Work

I cant seem to get this code to work. Can someone please show me what I did wrong!

<?php

$flavor="choco";

echo "Your favorite flavor of ice cream is ";

echo $flavor;

echo ".";

echo "Randy's favorite flavor is cookie dough, also!";

?>

2 Answers

Andrew Kiernan
Andrew Kiernan
26,892 Points

Hi Alec!

I'm not sure which step of the challenge is tripping you up, but I assume its the step with the conditional? If that's the case, you want to wrap the final echo statement in an "if" statement. It will look like this:

if ($flavor == "cookie dough") {
  echo "Randy's favorite flavor is cookie dough, also!"
};
John Breiner
John Breiner
6,918 Points

Andrew is on the right part for the conditional, I thought I'd show you a cleaner way to do the code for the other statement.

echo "Your favorite flavor of ice cream is " . $flavor . ".";