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 Creating the Menu and Footer Variables and Conditionals

need help

anyone know how todo the last code challenge with the conditional?

1 Answer

Erik McClintock
Erik McClintock
45,783 Points

Angus,

For the 3rd task, we want to use a simple if statement to check if the value stored in our $flavor variable is equal to Randy's favorite flavor of 'cookie dough'. Recalling the syntax for this type of conditional, we would write:

if( $flavor == 'cookie dough' ) {
    // echo statement goes here
}

Remember, the above logic says that "if (whatever is stored in the $flavor variable) is equal to 'cookie dough', then ....". So, if your favorite flavor is indeed cookie dough, and that is what you have stored in your $flavor variable, then the final echo statement will run! Otherwise, that last echo statement will be stepped over.

Erik