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

PHP Data & Structures Challenge 2 of 2

How is this wrong?

index.php
<?php

$name = Mike;

?>

<?php echo $name ?>

4 Answers

Hi David,

Actually you should avoid DRY (don't repeat yourself) to add twice PHP and forgot semi-colon, let's modify like below:

<?php

$name = "Mike";

echo $name;

?>
Ken Alger
STAFF
Ken Alger
Treehouse Teacher

David;

You are assigning the variable $name to an undefined constant, Mike. To get the results I believe you are wanting you need:

$name = "Mike";

More about PHP variables.

More about PHP constants.

Hope it helps,

Ken

Mike is a string and needs to be wrapped in quotes.

Also you need to terminate each line of code with a ;

<?php

$name = "Mike";
echo $name;

?>
Teresa Tribolet
Teresa Tribolet
11,286 Points

I am having the exact same issue. I tried like this...

<?php 

$name = "Mike";
echo $name;

?>

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

I also tried this and got the same error.

<?php 

$name = "Mike";
echo $name;

?>

<php? echo $name ?>