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

Task 2 of 2 wont work

No matter how many different ways I type it the second task will not display the contents of the $name variable which is Mike.

I've typed it as <?php echo $name ?> <p><?php echo $name ?></p> and <?php echo $name; ?>

nothing seems to work.

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


<!DOCTYPE html>
<html>
  <body>
    <h1><?php echo $name ?></h1>
  </body>

</html>

4 Answers

Yep, I understand. Sometimes the challenge can be picky about what it will accept. In this case, it will not accept two separate php code blocks. So, the solution looks like this:

<?php

  $name = "Mike";
  echo $name;

?>

Cheers

Hi Doug,

There's no need to create all that html - instead, echo the $name variable right below where it gets assigned the value "Mike".

Cheers

I did in the first attempt, it looked just like this:

<?php echo $name; ?>

The HTML was my last ditch effort in an act of frustration. :/

That did the trick! Thanks!