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 trialTimothy White
2,366 PointsI am certain I have the correct answer for the challenge "Now echo Mike's Name To The Screen" and cannot move forward.
I have also tried a variation where I include all the relevant HTML tags (DOCTYPE, html, h1) and still cannot move forward. Thanks!
<?php
$name = "Mike";
?>
<?php echo $name ?>
2 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsYou've almost done it. :) You just need to add a semi colon to your php code block to close the statement. When it comes to syntax PHP can be very strict.
<?php
$name = "Mike";
?>
<?php echo $name; ?>
Timothy White
2,366 PointsThanks, but unfortunately that also did not work. I have tried
<?php
$name = "Mike";
?>
<?php echo $name; ?>
...as well as...
<?php
$name = "Mike";
?>
<!DOCTYPE html>
<html>
<body>
<h1><?php echo $name; ?></h1>
</body>
</html>
Still not sure what I'm doing wrong?
Jonathan Grieve
Treehouse Moderator 91,253 PointsTry putting both statements into one code block.
This would make sense as the code is probably not picking up the reference to the value in the $name variable as it's in another block.
<?php
$name = "Mike";
echo $name;
?>
Timothy White
2,366 PointsThanks! that worked
Rich Donnellan
Treehouse Moderator 27,696 PointsTimothy,
You can include the echo
statement in the previous objective's tags (which passed on my end).
<?php
$name = "Mike";
echo $name;
?>
Hope this helps!
Timothy White
2,366 PointsThanks! that worked
Timothy White
2,366 PointsTimothy White
2,366 PointsThis is the other code that I've tried unsuccessfully. Any input as to what's wrong would be appreciated!