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

Can't pass PHP code challenge

Hey Randy,

I can't pass the last part of the code challenge on this page:

http://teamtreehouse.com/library/programming/build-a-simple-php-application/creating-the-menu-and-footer/variables-and-conditionals

Here is what I have so far:

<?php $flavor = "banana"; 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>"; }

?>

It's confusing to me, as anywhere I try to change the $flavor variable value, it gives me errors.

Please help.

Thanks in advance

5 Answers

Hey Pavel, the last task 4/4 wants you to change your $flavor variable declared on line 2 to 'cookie dough' to make sure that your conditional works and that "Randy's favorite flavor is cookie dough, also!" is displayed.

So you'd change $flavor = 'banana'; to $flavor = 'cookie dough'; which should mean that you'd enter inside the conditional. Let me know if it works!

Also just noticed, your pasted code here has your if statement comparing to "cookie dough." could that period be tripping you up?

Thanks Sam!

It was "cookie dough." in the requirement, and I've copied it exactly, just to be on the safe side. Now it works ok :)

Great to hear Pavel. Hope you have fun with the rest of the lessons, I really enjoyed them :smiley:

Hello, I am stuck on this one as well, I tried the above solutions and still get errors. I have began a post asking for help.