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

Geoffrey Neal
Geoffrey Neal
30,298 Points

I can't get task 2 to work for this code challenge, what am I doing wrong?

The task is to echo the variable "name" onto the screen. My code should be attached, maybe I've missed something obvious or misunderstood the question but as far as I can tell this should work. Can anyone see why it doesn't?

index.php
<?php

$name = "Mike";

?>

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title><?php echo $name; ?></title>
  </head>
  <body>
    <h1><?php echo $name; ?></h1>
  </body>
</html>

1 Answer

Andrew McCormick
Andrew McCormick
17,730 Points

technically you're correct, but looks like all they wanted is:

<?php

$name = "Mike";
 echo $name;
?>
Geoffrey Neal
Geoffrey Neal
30,298 Points

Ah...Knew I'd over complicated it. Thanks.