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 trialKaeley Cheng
Courses Plus Student 711 PointsI don't know what is this question ask for and not sure what to do, please help out. Thanks a lot!
<?php $name="Mike"
echo $name;
?>
<?php
$name = "Mike" ;
echo $name;
?>
5 Answers
David Tonge
Courses Plus Student 45,640 PointsI just went back to the challenge and it's basically asking exactly what you have for your second example.
<?php
// The first half asked you to create a variable set to the String "Mike"
$name = "Mike";
// The second half just asked to echo "Mike" to the screen using the variable.
echo $name;
?>
Also, always pay attention to your semi-colons.
Kaeley Cheng
Courses Plus Student 711 PointsIt looks the same to me. I don't know where I did wrong
David Tonge
Courses Plus Student 45,640 PointsYou were missing a semi-colon above, right after the word "Mike". Just copy and paste the formatted example in it will pass. I just tried it twice.
Kaeley Cheng
Courses Plus Student 711 PointsYep~ It works. Maybe I should not put a space after 'Mike". Thank U!
Lewis Cowles
74,902 PointsSorry I did not notice sooner Kaeley, Treehouse notified me, but I was out as it's saturday lol... You can have a space after "mike", and the semi-colon does not even have to come on the same line for PHP (not sure about the test criteria); but you do need a semi-colon separating statements in PHP, and it is considered best practice to put them clearly visible on the same line as the statement ends, because it makes it easier to check for their absence.
so
<?php // open PHP
$name = "Mike"; // notice both quotes are double quotes
$name = 'Mike'; // This is not needed, but also valid, as both quotes are single quotes, it's about the quotes being the same
echo $name; // put $name in the output stream, which in a webpage comes out on the page as text
// you do not need to include any close tag unless you have non-PHP after the PHP ?>
Hope this adds a little to your understnding of David's answer and PHP in general :D
Kaeley Cheng
Courses Plus Student 711 PointsThanks for the response