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 Basic PHP Website (2018) Building a Media Library in PHP Variables and Conditionals

Alexey Korovenkov
Alexey Korovenkov
3,653 Points

PHP task. This should be correct.

This should be correct. I do not understand what's wrong.

Of course, English is a foreign language for me, but code should be correct. And I do not see the preview, only white screen.

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

?>
Alexey Korovenkov
Alexey Korovenkov
3,653 Points

I just added "echo $flavor;", but it looks strange, I thought need to add inside text.

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

?>

1 Answer

Hi Alexey,

You seem to be misreading the question.

The first part of the challenge is to create a variable named flavor and assign your favourite flavour to it.

So your code at Step 1 should be something like:-

$flavor = "some flavour";

In Step 2 of the challenge you then need to echo out that variable instead of echoing the string "vanilla" as you have.

eg.

echo $myVariable;

As your code is written on your second post you have a variable of $flavor which is just an empty string. Then when you echo that variable on the next line it just echoes the empty string.

Hope that makes sense and helps :-)

Cheers Don

Alexey Korovenkov
Alexey Korovenkov
3,653 Points

Yes, sometimes it's hard to understand the meaning. I understand more than 90% of the material in lections. And often understand the text without google translate, but not always. Sometimes I understand the answer, before I can understand the question. Because sometimes it's easier, understand code, than English. And It looks like I'm already starting to memorize new English words "quiz","semicolon","comma".

Hey Alexey,

Glad I was able to help and yes, I've often thought it must be difficult for people from non English-speaking backgrounds to learn to code. You're essentially learning two languages at the same time!

Keep at it, I am sure it will come more naturally to you with time :-)

Cheers Don