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 - 4/4

[alt text](Macintosh HD/users/alanking/desktop/code.jpg) [alt text](Macintosh HD/users/alanking/desktop/code-preview.jpg) In case the jpegs don't show up here's the code: ''' <?php $flavor="cookie dough"; echo "<p>Your favorite flavor of ice cream is "; echo $flavor; echo ".</p>"; if($flavor == "cookie dough"){ echo "<p></p>";} ?> ''' When I Preview I get "Your favorite flavor of ice cream is vanilla." even with the var changed to "cookie dough". When I Check Code I get: "Oops! It looks like Task 3 is no longer passing."

6 Answers

Rodger Voelkel
Rodger Voelkel
21,736 Points
<?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>"; }

?>

When it says preview make sure you hit refresh that is provided by the challenge not your browser refresh...that will update the flavor variable, not having the echo text at the end correct is making task 3 fail i believe

Philip Cox
Philip Cox
14,818 Points

Hi Alan, try adding the three back ticks before and after your code section, this can make it a little more clear. I think I could help you better then :)

php echo $name;

Well, you learn something new every day. I'd never noticed those back ticks up there at the top of the keyboard.

<?php $flavor="cookie dough"; echo "Your favorite flavor of ice cream is "; echo $flavor; echo "."; if($flavor == "cookie dough"){ echo "";} ?>

Hope that helps. Thanks in advance.

Philip Cox
Philip Cox
14,818 Points

And you want your final outcome to be what? An echo of "Your favourite flavour of ice-cream is Vanilla"?

Yes. I realize the last conditional clause would result in nothing showing up but I've tried leaving it off and also inserting text "Your favorite flavor of ice cream is" with $flavor but I get the same result.

Philip Cox
Philip Cox
14,818 Points

As long as you have changed the variable to Cookie Dough, then yes it should be correct. Try restarting the challenges by going back then forward with the course arrows. I like doing this as I get to go over them again. ```php $flavor = "cookie dough"; if ($flavor == "cookie dough") { echo ....... }

Actually no. The required answer is cookie dough, But I keep getting vanilla.

Thank you, Rodger. It worked!