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

Deleted User

Build a simple PHP application > Creating the menu and footer > Code Challenge: Variables and Conditionals > Task: 3/4

someone can do it?

14 Answers

James Barnett
James Barnett
39,199 Points

Here's a hint, the question is asking you to echo the variable flavor not the literal text.

James Barnett
James Barnett
39,199 Points

In the future try to keep your title nice and short so someone looking through the forum and easily read it a glance.

5 to 10 words is generally a good length.

The title of your post was cut off because it exceeded the max length of the title field of 255 characters.

Here's are some tips on how to ask better questions on forums.

Deleted User

James thanks for the note. btw i can't pass the task 3 #Help

James Barnett
James Barnett
39,199 Points

@Mohamed -

Post the code you have so far into a PHP playground.

Deleted User

Done

Deleted User

I posted my code there but realy i don't get the next step, after that , what i'm gonna do?

James Barnett
James Barnett
39,199 Points

What's the link to the PHP code you posted?

Deleted User
James Barnett
James Barnett
39,199 Points

Now you need a conditional to test to see if the variable flavor is equal to cookie dough and if so output Randy's favorite flavor is cookie dough, also..

Otherwise if the flavor is equal to something else, writing "also" at the end of the sentence would not be grammatically correct, so the string should instead say Randy's favorite flavor is cookie dough.

Let us know how you are getting along and if you need any more help.

Deleted User

@James -

i have done , here is the link

http://codepad.viper-7.com/OcpQlc

thanks for the helping :)

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

Hey @Mohamed,

That code is close but not quite correct. Line 4 should look like this:

echo $flavor;

In line 2, you set the variable to have a value. In line 4, you are supposed to echo out whatever value is in the variable. Does that make sense?

James Barnett
James Barnett
39,199 Points

You need an else because if I change the value assigned to flavor to something other than cookir dough it now no longer print out what Randy's favorite flavor is.

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

Actually, James, that's the desired behavior. The code challenge says to display the message about my favorite flavor if our favorite flavors are the same. This paragraph wouldn't make any sense:

Your favorite flavor of ice cream is strawberry. Randy's favorite flavor is cookie dough, also!

The conditional should make sure the second sentence only shows when they are the same.

James Barnett
James Barnett
39,199 Points

@Randy - Oops, that's what I get for not going back and checking the the instructions on the code challenge.