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

sebastian rojas
sebastian rojas
571 Points

code challenge help?!

Im so tired haha do anyone know the right code for this?

3 Answers

Challenge 4 is a Bummer because it states "Change the value in the flavor variable to cookie dough. Preview the code and make sure the message appears." Then one of the error messages is "Bummer! Be sure to add a conditional to hide the message." This could bee a little confusing, especially at this stage of the game.

I'm going to post the code below; look at it carefully.

Jeff

Code Challenge 1 of 4

<?php
$flavor = "chocolete";

echo "<p>Your favorite flavor of ice cream is ";
echo "vanilla";
echo ".</p>";
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";

?>

Code Challenge 2 of 4

<?php
$flavor = "chocolete";

echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";

?>

Code Challenge 3 of 4

<?php
$flavor = "chocolete";

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

?>

Code Challenge 4 of 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>";
}

?>

Sebastian,

What question are you referring to?

Jeff

sebastian rojas
sebastian rojas
571 Points

I'm at stage 4 and really dont know what to do! "Change the value in the flavor variable to cookie dough. Preview the code and make sure the message appears.

the code is "<?php $flavor = "chocolate"; echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; if ($flavor == "Cookie Dough") { echo "Randy's favorite flavor is cookie dough, also!"; } ?>

I am new on this website so im not quiet sure how i can explain on what challenge i am but it's about flavors :)

On the fourth question you are asked to change the $flavor variable to "cookie dough" (all lower case). After doing this the if conditional will be true and the echo statement will execute, providing you type $favor == "cookie dough" and not $favor == "Cookie Dough".

Jeff

sebastian rojas
sebastian rojas
571 Points
            Well if i change that it will say that my information does not match with stage for example 1 etc.. but the code im using now gives me this  as an error when im trying to pass the challenge "Bummer! Be sure to add a conditional to hide the message." when im using the code i wrote in comment.

Could you copy the code for me here?

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

that code worked for me i just had to start from challenge 1 again! :)