Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,019 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;
?>