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

PHP Conditionals

Which part do you need help with?

2 Answers

  1. set your variable on line 2. Remember variables start with a $ and one = sets the new variable equal to your value. For strings don't forget the quotes.
  2. Modify the echo statement on line 4 to print your variable.
  3. Change the echo statement "echo "<p>Randy's favorite flavor is cookie dough, also!</p>";" into a conditional that only prints the echo statement if your value is equal to the string "cookie dough". Remember a conditional uses an if ($x_variable equals $y_variable) {then do something} syntax. Your do something in this case is the echo statement. And, one = will not work. If you don't remember why this is, its an easy Google or go back in the videos search away. Hope that helps and best of luck! Any other questions just post. Happy to help!
Jetro Tull Roa
Jetro Tull Roa
7,051 Points
  1. $flavor = "flovor_of_icecream_here"; (put this on line 2)

  2. change the static message on line 4 to your new variable (click preview to see the output)

  3. for conditional you should use "if". pls sample below: use == for comparison. if ($variable == "something or another $variable) { here u need to put what to do if it meets the condition. eg. echo "something"; }

  4. change the variable value on line 2 to "cookie dough" which is the same favorite flavor as Randy. (click preview to see the output)