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 is wrong with this code?

Why is the output not accepting the correct answer?

index.php
<?php

$name = "Mike";

?>

<<?php echo $name ?>

6 Answers

You have added an extra character (<) before the second php part.

<?php

$name = "Mike";
echo $name;

?>

Otherwise what you did is right as well, except for the extra character as I mentioned.

Yea I copied and pasted and its not still not working

You have to pass the variable to the echo. Something like this

<?php
$name = "Mike";
 echo $name;
?>

I did both of your suggestions and it is still getting it wrong.

If you are sure of what you typed, copy and past the code I put. It should work, I don't know why but this exercise seems a bit bugged. I've seen others people getting a similar issue and by copying the code, that worked... Tell me what after that.

echo "Mike";

This is what I entered <?php $name = "mike" echo $name; ?>

Even if what you did previously seemed to be right, test with this code.

<?php
$name = "Mike";
echo $name
?>

It seems It has worked for another person, check this topic.

The only difference is that the last line doesn't end with a semicolon... Fortunately I don't often see such issues with code challenge here at treehouse.

I got it right! Thank you!

Glad that worked ;) !