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
Thomas Vasey
1,371 PointsTrouble with Build a simple PHP application Challenge Task 4
Hi there, I'm having trouble with Task 4 on the Challenge for 'Build a Simple PHP application' videos. Here is my code:
<?php
$flavor = "vanilla";
if($flavor == "vanilla") { echo "<p>Your favorite flavor of ice cream is " . $flavor . ".</p>"; }
if($flavor == "cookie dough") { echo "<p>Randys favorite flavor is " . $flavor . ", also!</p>"; } ?> It isn't validating when I change the $flavor variable to 'cookie dough' and tells me that Task 2 is incomplete. Thanks for your time. Regards.. Tom
3 Answers
Moriah Sella
Courses Plus Student 25,814 PointsHI Thomas if you follow the challenge step by step: <?php
// Task 1
$flavor = 'vanilla';
//Task 2
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
// Task 3
if($flavor == 'cookie dough'){
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
}
//Task 4 - change the value in the variable
$flavor = 'cookie dough';
//preview the page and you will see that the message in the "if" conditional will be shown
Thomas Vasey
1,371 PointsAh that's great, took me a while. Little bit confusing, I'll remember to keep the format the same as it's presented to me.
Thanks again for your time.
Kind regards,
Tom.
Ales Petrovacki
3,454 PointsYou should not change $flavor up the code ... you just create new $flavor as Moriah wrote to you. :)