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 code challenge task 3 of 4

I can not seem to pass the 3rd task of the code challenge: build a simple php application. here is the question:

The message in the final echo command only makes sense if your favorite flavor is the same as mine. 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.

here's what I have:

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

?>

can someone help me out, thanks!

6 Answers

Stone Preston
Stone Preston
42,016 Points
if ($flavor == 'cookie dough';) {echo "<p>Randy's favorite flavor is cookie dough, also!</p>";};

You have a semicolon at the end of the if statement block. Try removing that and see if it works

Hi Stone, I took that ; out and I passed. Thanks so much, I was stuck on that one for a while!

Julian Price
Julian Price
11,760 Points

I have been so stuck on this model too but at 2 of 4 of the variable and conditionals code challenge. I am not real clear what the question asking because i am using the if statements

The question is asking for you to use the variable that you created in task 1. So instead of line 4 saying

echo "vanilla";

you want it to echo your $flavor

Julian Price
Julian Price
11,760 Points

Thanks Aaron I finally completed. I had to come back after listening to later videos but did it.

Awesome! It's a good feeling when you get it right.