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 trialDanny Outlaw
677 PointsPHP Data & Structures Challenge 2 of 2
How is this wrong?
<?php
$name = Mike;
?>
<?php echo $name ?>
4 Answers
Salman Akram
Courses Plus Student 40,065 PointsHi 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
Treehouse TeacherDavid;
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
Dan Martin
33,150 PointsMike 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
11,286 PointsI 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 ?>