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

Yolanda Guerra
Yolanda Guerra
3,290 Points

What is the answer

I have tried a number of combinations trying the get the stupid variable to work and it won't. What is the answer

index.php
<?php
$flavor = "vanilla";
<? php echo "<p>Your favorite flavor of ice cream is "; ?>
<? php echo $flavor; ?>
<? php echo ".</p>"; ?>
<? php echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
?>

Hi Yolanda, u almost got it right. What i would suggest is to double check your closing and opening php tags on each line.

Hint from me: Break each line apart and it should become much clearer what and where needs to be fixed. Let us know what did u came up with :) U almost there !

3 Answers

Kris Phelps
Kris Phelps
7,609 Points

Hey Yolanda,

You have a space between the <? and php in your opening tags. An opening tag should look like this:

<?php

And you have nested php opening and closing tags.

Thanks Kris for your contribution, one thing that i would like to add. I do believe that it's much better to give people hints and tips rather than ready solutions, they need to think and its much more rewarding and sticks in your head far better when u can solve a puzzle by yourself or with "little" help in form of a hint from the outside, especially whilst learning new things.

On the other hand, removing the white space between the question mark and php isn't the only problem here :)

Kris Phelps
Kris Phelps
7,609 Points

I agree. She just seemed really frustrated, so I thought it would be nice to help out. Thanks for the tip though :-)

I do understand her frustration, probably every each of us had that moment when u think u have tried everything and it doesn't seem to work, it can become really annoying at times. Using as an example my own learning style and books i recently read about learning styles and human ability to solve problems, an (in my opinion) good advice i would like to share with everyone who has that brick wall moment (and only when u really run out of solutions to your problem), is to leave the problem for 10-15 minutes, listen to some music, do some sudoku, meditate etc. whatever takes you out of that "confused" state and let you brain do it's magic in the background (without you even thinking about it), quite often, the solution can come to you in a so called "flash". Worked for me plenty of times :)

Another thing with Yolanda's code is, like i said earlier, to break it apart a bit and and check it piece by piece. I do believe that after few minutes of break and when she re-thinks it again, she will really quickly reach that AHA! moment :)

Yolanda Guerra
Yolanda Guerra
3,290 Points

Thank you Kris and Pav the combination from both of your answers helped me. I went back and started from the beginning and took a guess again and it worked. Being brand new to php sometimes it is hard to see the simple solutions and even though you may have thought the answer was handed to me it really wasn't. Because I'm so new I had to figure out exactly what Kris was referring to, that in itself was another challenge. In the end both suggestions helped. Thank you

Kris Phelps
Kris Phelps
7,609 Points

You're very welcome, Yolanda. I'm glad you were able to learn in the process. I hope you have a ton of success on Treehouse. :-)

Hi Yolanda, great news !

Could we possibly see the code that worked for you ? and could u write about the way u came up with you final solution ? was it more of a try and error method ? Share it with us :)