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 am trying to echo the name variable on to the page but cannot figure out why it isn't showing up

I am doing it exactly how i was shown in the video and everything but the test is telling me it is not showing up in the output.

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

<h1>
  <?php echo $name ?>
</h1>

1 Answer

Jeff Lemay
Jeff Lemay
14,268 Points

Your code is almost correct but the main issue is the challenge wants you to put all the php in a single php block.

They also ask you to just echo the name variable, you don't need the h1 tags.

And I would add a semi-colon after you echo the name variable (not required in this case but I stick to closing all my statements with semi-colons just to be safe).

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

Thank you! I didnt realize it wanted me to do it all in one block. Also thanks for the advice.

Jeff Lemay
Jeff Lemay
14,268 Points

The challenge doesn't mention that it needs to be in one block. It probably should though since this problem has come up a few times recently.