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 trialBart Poelstra
2,385 PointsI'm trying to echo mike's name in the output. So I thought: <?php echo $name ?> But that seems incorrect.
Hope someone can help! :)
<?php
$name = "Mike";
?>
<?php echo $name ?>
2 Answers
Ted Sumner
Courses Plus Student 17,967 PointsI just took the challenge and passed with this code:
<?php
$name = "Mike";
echo $name;
I see a couple of things that might be preventing passing the challenge. Most importantly, you are missing the ; after your echo statement. Second, you do not not need to close and open your php between the variable and echo.
You may notice that I did not close my php. You do not have to close if all the code on the page is php.
Jeff Lemay
14,268 PointsThis challenge comes up frequently. They want all your code in a single php block (like Ted's answer, although I always close my php no matter what just to be safe).
Your code is "correct", just not what the challenge wants.
Ted Sumner
Courses Plus Student 17,967 PointsIn the later php courses they say it is best practice to not close if you can because of white space issues.
Jeff Lemay
14,268 PointsHmm I'll have to check that out. Thanks for the info!