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

PHP PHP Basics (Retired) PHP Data & Structure PHP Variables

I've tried this with and without returns to the next lines, and with and without semicolons.... and with and w/o html.

Please help! Why isn't this working??? I've tried it 8 different ways!

index.php
<?php 
$name = "Mike";
echo $name;
?>

2 Answers

Greg Kaleka
Greg Kaleka
39,021 Points

Hi Creighton,

You may want to refresh the page or something. Your code is correct. In fact, I copied and pasted your code directly into the challenge and was able to pass.

Refreshed the page with the same code 4 times, and on the 4th, it worked after removing the semi-colon following "echo $name".

Thanks Greg.

Greg Kaleka
Greg Kaleka
39,021 Points

Very strange... The last statement in a php block doesn't need a semicolon (though it's good practice to always use them). There's no reason why you should have had to remove it. Must have been a glitch. I think it's a coincidence that it worked when you removed the semicolon.

Anyway, glad you got it to go through!