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

Piccia Neri
Piccia Neri
8,937 Points

If I can't work out what the solution is, where can I find the answer?

I can't get my head around this and it would be really useful to be able to see the answer somewhere so I can understand. Not revealing the answer anywhere when a student is stumped doesn't really help learning. If i could see the answer to this now, I would understand it.

index.php
<?php
$flavor ="chocolate";

echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
if ($flavor == "chocolate) { 
echo "<p>Randy's favorite flavor is cookie dough, also!</p>";
}

?>

2 Answers

Greg Kaleka
Greg Kaleka
39,021 Points

There are a couple of things wrong with your code. The first is technical: you have a typo in your if statement - you're missing a closing ". The second is conceptual: If your favorite flavor is chocolate, the output doesn't make any sense! You should be checking to see if the flavor is cookie dough :).

Piccia Neri
Piccia Neri
8,937 Points

Hi Greg, I thought I'd already answered but it must gone lost in cyberspace – thanks for your answer first of all.

However, my problem relates in general to code challenges: it does not help my learning at all if when I am absolutely stumped I cannot see the answers anywhere. I don't care if I don't earn any points – I just want to be told what I am not getting right so that I can understand it and move on. It would be very useful if answers were somehow accessible – with a points penalty, fine – but I don't really care about the points, I care about understanding.

As for the code, the problem is indeed conceptual: it doesn't make any sense to me that I should check if the flavour is cookie dough. If I hadn't read the sentence, I wouldn't even know that cookie dough existed as a flavour. And if I have read the sentence, because it already exists, what's the point of checking?

So yes, I probably don't think like a coder and that's why I was absolutely stumped.

But the code challenge issue has come up for me before and I would be really grateful if someone from Treehouse could take it into consideration. You should make the answers available somehow because being stuck is just not helpful in any way.

many thanks, now the code is indeed right!

Greg Kaleka
Greg Kaleka
39,021 Points

No worries. It can be tough to get your head around some of these concepts, and because when you're learning, the examples have to stay simple, you can get hung up on things like "why am I checking this when I can see it?!". Eventually, you'll be working on more complex projects, where the input is unknown, and you'll want to check to see what it is.

In general, these code challenges are like real coding: if you can't figure something out, it's time to start searching forums like this one, or stack exchange, or just googling it.

Specifically for these code challenges, though, oftentimes the best thing to do is to go back to the video just before it, and scroll down to look at the "Questions." It's possible someone has had the same problem as you, and it's very likely someone has posted the solution in response to someone's question.

Good luck!