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

Don Macarthur
Don Macarthur
28,278 Points

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".

Don Macarthur
Don Macarthur
28,278 Points

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