Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

Deleted User

PHP Variables and Conditionals code challenge

Hi i wonder if someone could help me here? Im stuck on the last question of the code challenge. On Variables and Conditionals and i have absolutely no idea what to do. Everything i try seems to be wrong it driving me mad.

the question is:

Change the value in the flavor variable to cookie dough. Preview the code and make sure the message appears. Your code from each task should be added to the code written in the previous task.

my code:

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

?>

6 Answers

Deleted User

Figured it out guys i only needed the one $flavor =""; Variable dont no why i thought i needed two lol i wont be making that mistake again XD

Nick Pettit
STAFF
Nick Pettit
Treehouse Teacher

Hey Robbie,

Glad you were able to resolve this. :) It looks like you're having fun with coding though, which is great. Writing code can be difficult at times, but patience and a sense of humor helps!

I am stuck on the final part of the quiz, I have changed the variables to cookie dough and it still tells me that I am wrong. I have been going back and forth here and its driving me nuts.

<?php $flavor = "cookie dough"; echo "<p>Your favorite flavor of ice cream is "; if ($flavor == "cookie dough"){ echo "cookie dough"; } if ($flavor == "vanilla"){ echo "off"; } echo ".</p>";

$flavor = "cookie dough"; echo "<p>Randy's favorite flavor is also "; if ($flavor =="cookie dough"){ echo "cookie dough"; } if ($flavor == "vanilla"){ echo "off"; } echo "!</p>"; ?>

Never mind I figured it out and I saw what went wrong.

Sebastian Wilson
Sebastian Wilson
15,710 Points

I keep on getting an issue with the final task, my issue is that it tells me "Oops! It looks like Task 3 is no longer passing." When I change the value of $flavor

TASK 4

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

?>

TASK 3 Passes

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