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 trialadrien kovanic
5,727 Pointshi I am asked to echo mike's name, so I put <?php echo $name ?> bu that doesn't work...
thanks for you help (and yes $names = "Mike";
<?php
$name = "Mike";
?>
<?php echo $name ?>
4 Answers
Gloria Dwomoh
13,116 PointsTry adding the echo in the same PHP tag where the name variable is defined.
adrien kovanic
5,727 Pointsok thanks :)
Gloria Dwomoh
13,116 PointsYou are welcome.
eddie
8,289 PointsActually, they don't need to be in the same PHP tag. Everything in previous PHP tags on the same page persists throughout that page. The only problem I see is you left out the semicolon after "echo $name".
Gloria Dwomoh
13,116 Pointseddie - It needs to be in the same PHP tag because if you see in the 1st task the instructor asks you to create a PHP block and a variable, in the second task it asks to echo a statement without asking for a 2nd block. The challenges need to be solved based on what they ask because things get tricky sometimes when you try alternative methods, if you try your suggestion you'll see that. The semicolon issue is something that depends. According to the documentation of PHP "As in C or Perl, PHP requires instructions to be terminated with a semicolon at the end of each statement. The closing tag of a block of PHP code automatically implies a semicolon; you do not need to have a semicolon terminating the last line of a PHP block. "
eddie
8,289 PointsAhh. I wasn't aware this was related to a challenge. Some of them are frustrating like that. You know your way works, but they want you to do it their way.
Gloria Dwomoh
13,116 PointsNo worries, and yes that is true.
Eric Jefcoat
2,946 PointsAwesome. Teach it one way. Test on it another way and throw in a technicality that wasn't mentioned. I'll remember to review my "No Child Left Behind" test-taking tips before I complete another task.
Thank you for the help though. It is appreciated. Just frustrated that I was checking my notes and my code and couldn't see my "error."