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
Jonah Ollman
3,459 PointsWhy does this code not work?
Why does the output not show "Mike"?
<?php
$name = "Mike";
?>
<?php echo $name ?>
4 Answers
James Gill
Courses Plus Student 34,936 PointsJonah,
You'll need to put the variable and the echo statement inside the same php tags, and add a semicolon after the echo statement. So:
<?php
$name = "Mike";
echo $name;
?>
Sometimes, what you're doing will work within two php tags, but I haven't seen it work in the Treehouse code editor.
hope that helps, -james
Jonah Ollman
3,459 PointsStill doesn't work. This is in the PHP Basics class on the PHP Variables challenge
Jonah Ollman
3,459 PointsThanks James! It works!
James Gill
Courses Plus Student 34,936 PointsExcellent! As I progress, the most common errors I make are small syntax errors (like, say, omitting semicolons). When in doubt (and to save time), check that stuff first.
David Finley
8,350 Pointsno semicolon after $name Should be <?php echo $name; ?>