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

Shahzain Hashmi
Shahzain Hashmi
2,360 Points

Variable Is not echoing

I have named the variable, however when trying to echo Mike's name, it doesn't work. Could you tell me where I'm going wrong?

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

<?php echo $name ?>

1 Answer

Greg Kaleka
Greg Kaleka
39,021 Points

Hi Shahzain,

I've seen this get people before! The challenge wants you to only use a single PHP block. In real life, there's no reason to only use one, but that's what the challenge is looking for. Your code is otherwise perfect (though it's best practice to always use semicolons!), so all you have to do is mash it together:

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