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

Don Shipley
Don Shipley
19,488 Points

Modify the command that displays the flavor of ice cream. Instead of it displaying a static piece of text, change it to

<?php $flavor = "vanilla"; // if I change the variable here test 3 will no longer pass. echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>";

// If I place a variable here to change to cookie dough task three will not pass. if($flavor == "cookie dough"){ echo "<p>Randy's favorite flavor is $flavor , also!</p>"; }

?> <p> <?php // if I add a new block and the variable of cookie dough here task 2 will not pass. $flavor = "cookie dough"; echo "<p>Randy's favorite flavor is $flavor , also!</p>"; ?>

1 Answer

Gareth Borcherds
Gareth Borcherds
9,372 Points

Here's what it looks like at the end

<?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>";
}
?>
Don Shipley
Don Shipley
19,488 Points

Instead of trying with the same block I added this to the end of the block.. Guess in the test question you need to add a whole new block so the variable will not change the first block. with just the $flavor = "cookie dough"; if($flavor == "cookie dough"){ echo "<p>Randy's favorite flavor is $flavor, also!</p>"; } which did not pass. Thank you just added yours to the end and passed.