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

Adding Active States to the Navigation

I am at task 2 of this code challenge and cannot move forward, the task asks to: 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. The current code is <?php $flavor = "vanilla"; ?> but I have tried to modify this in several ways without any success, any help would be appreciated.

Jonathan Becher
seal-mask
.a{fill-rule:evenodd;}techdegree
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 Points

It's asking you to display, which I hope I am understanding correctly, the variable $flavor's value. As in print it to the screen. Am I correct in assuming this or am I wrong?

Hey Jonathan, thanks for responding, to be fair I am not too sure, however the variable's value has already been output so I am not really understanding what the 2nd task is really asking...

Thanks Jonathan, I'd tried that already, but it doesn't work...

This looks like the "Variables & Conditionals" code challenge in Build a Simple PHP Application, though the challenge is working just fine for me:

<?php
$flavor = "chocolate"; // This variable was added in task one.
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor; // Changed to complete task two.
echo ".</p>";
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";

?>

Yes that's the code challenge, but for me doesn't want to work... Starting to lose my hope, could it be that the code submission functionality from Treehouse isn't working properly?

2 Answers

Jonathan Becher
seal-mask
.a{fill-rule:evenodd;}techdegree
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 Points

Okay, I've figured the problem out. the last line was the line that needed to be changed, from a static line of text, to printing the value stored, so that they would match up.

change: <br> echo "<p>Randy's favorite flavor is cookie dough, also!</p>";

To: <br> echo "<p>Randy's favorite flavor is "; <br> echo $flavor; <br> echo ", also!</p>";

Ah, that would be task three. He said it was task two above though, though you're completely right.

Hi guys, thanks for the help, but like Balley mentioned I am on task number 2, which asks to modify the command that displays the flavor of ice cream and instead of it displaying a static piece of text, change it to display the value stored in the 'flavor' variable.

Can you copy and paste the code you're inputting? This is an odd error to encounter.

I managed to sort all tasks apart from 4 now, which says: Change the value in the flavor variable to cookie dough. Preview the code and make sure the message appears.

<?php $flavor = "vanilla"; // This variable was added in task one. echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; echo "<p>Randy's favorite flavor is vanilla, also!</p>"; $flavor = "cookie dough"; ?>

You want to change the initial variable to cookie dough instead of redefining it at the end. So at the beginning: <?php $flavor = "cookie dough"; Then change the sentence about Randy to display the flavor variable instead of being static at vanilla. echo "Randy's favorite flavor is "; echo $flavor; echo ", also!"; ?>