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 trialLong Nguyen
11,485 PointsTask 4 of code challenge 1 in PHP development
Hi there,
Here is the code that I've written for task 4: <?php
echo "<p>Your favorite flavor of ice cream is "; $flavor = "vanilla"; echo $flavor; echo ".</p>"; $flavor = "cookie dough"; if ($flavor=="cookie dough"){ echo "<p>Randy's favorite flavor is cookie dough, also!</p>"; } ?>
I believe that code works fine but it keeps telling me that task 2 doesn't pass. Therefore, can anyone help me about this problem :(
2 Answers
Chris Dziewa
17,781 PointsMy working code:
<?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>";
endif;
?>
Note that you can use { }
instead of my : and endif
but right now you are reassigning the variable $flavor when you only need to replace "vanilla"
on the first line with "cookie dough"
.
Long Nguyen
11,485 Pointsooh :( I thought the task is to keep the output "Your favorite floavor of ice-cream is Vanilla" :-P Now, let me redo this again
Thank Chris
Chris Dziewa
17,781 PointsNo problem, Long! Here the test was just looking for you to change your favorite flavor so it outputs the conditional statement.