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 trialDaniele Manca
Courses Plus Student 7,548 PointsAdding 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.
Daniele Manca
Courses Plus Student 7,548 PointsHey 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...
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 PointsWhat activity in PHP is this in? Hmm, try out doing this..
<?php $flavor = "vanilla";
echo $flavor;
?>
Daniele Manca
Courses Plus Student 7,548 PointsThanks Jonathan, I'd tried that already, but it doesn't work...
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 PointsOkay. What course is this, and which activity along with which challenge. Once I get that I can better help you.
by4
34 PointsThis 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>";
?>
Daniele Manca
Courses Plus Student 7,548 PointsYes 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
Full Stack JavaScript Techdegree Student 4,655 PointsOkay, 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>";
by4
34 PointsAh, that would be task three. He said it was task two above though, though you're completely right.
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 PointsThanks for clarifying.
Daniele Manca
Courses Plus Student 7,548 PointsHi 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.
by4
34 PointsCan you copy and paste the code you're inputting? This is an odd error to encounter.
Daniele Manca
Courses Plus Student 7,548 PointsI 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"; ?>
by4
34 PointsYou 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!"; ?>
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 Pointsseems like you've just stated the answer I gave.
Jonathan Becher
Full Stack JavaScript Techdegree Student 4,655 PointsJonathan Becher
Full Stack JavaScript Techdegree Student 4,655 PointsIt'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?