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 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?

index.php
<?php
$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!

Then:

<?php $name = "Mike" ?>

<?php echo "$name" ?>

I still get it wrong.

What it's looking to appear is as follows:

<?php
$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.