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

Cursos7 Team
Cursos7 Team
4,745 Points

I have questions to resolve this issue, you can give a tip?

<?php

$flavor = 'vanilla'; echo $flavor;

index.php
<?php

$flavor = 'vanilla';
$flavor;



?>

2 Answers

Marileen Mennerich
Marileen Mennerich
1,161 Points

Which step of the challenge are you having troubles with? If it is the 2nd, make sure you do not delete all of the preexisting code. Just replace the plain text flavor with your variable, then it should work out.

Cursos7 Team
Cursos7 Team
4,745 Points

I'm in this question. Modify the command that displays the flavor of ice cream. Instead of it displaying a static piece of text, change it to display the value stored in the 'flavor' variable.

Cristian Altin
Cristian Altin
12,165 Points

Problem is that you deleted the rest of the code. You need to have $flavor = "vanilla"; at line 2 ,then you need to change only line 4 which is the static text of what by default is "your" fav ice cream flavor.

Keep the other lines since the exercise will build on that code.

Btw, don't forget echo.

Cursos7 Team
Cursos7 Team
4,745 Points

Change the value in the flavor variable to cookie dough. Preview the code and make sure the message appears.

<?php

$flavor = "chocolate"; echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>";

if($flavor == "vanilla"){

echo "<p>Randy's favorite flavor is cookie dough, also!</p>"; } ?>

It's wrong. Why?

Cristian Altin
Cristian Altin
12,165 Points

Always read the exercise at least twice and start writing when you get all the requirements.

It's telling you to "change the value in the flavor variable" to "cookie dough". Where did you set the $flavor variable? There you need to change it to the new text. ;-)

Oh and be sure to test the variable with the new flavor in the if where vanilla is now outdated, hehe.