Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics (Retired) PHP Data & Structure PHP Variables

What am I doing wrong?

In the challenge, I am being asked to echo "Mike" to the screen. I typed <?php echo "$name" ?> What am I doing wrong?

$name = "Mike";

<?php echo "Mike"?>

6 Answers

The challenge wants you to echo the variable that you had set. While it will work the way you have it once you swap in the variable the challenge also wants you to have both of those commands in the same PHP block.

I don't understand.

I've tried several things and nothing is working.

<?php $name = "Mike" ?>

Got that right!


<?php $name = "Mike" ?>

<?php echo "$name" ?>

I still get it wrong.

What it's looking to appear is as follows:

$name = "Mike";
echo $name;

That was a bit confusing.

I thought I was missing codes or something.

In my mind, it didn't make sense with out "replacing" it in the body code.

(If that makes sense.)

Thank you very much!

It still says it is wrong.

"Bummer! I am not seeing the word "Mike" in the output. Did you echo something different?"

Strange.. When I copy and paste my code into the challenge it passes with no issues. Can you paste what you have entered that is not passing with the changes made?

echo $name;

I logged in through a different computer and tried it and it worked.

How weird.

Thank you for you help!

Atrian Wagner
Atrian Wagner
24,811 Points

I had this exact same issue, and I figured out if there is a space after the code, then it won't accept it as correct.