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

Lucille daCosta
Lucille daCosta
2,286 Points

why isn't this working on the quiz? it's exactly what I did in the workspace. <h1><?php echo $name ?></h1>

Can't see why this is wrong on the quiz. I actually copied and pasted from my Treehouse workspace.

The top (which was marked correct) is <?php $name= "Mike"; ?> Thanks Lu

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

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

4 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Hi Lucille daCosta , you should do this instead.

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

Putting both line together. It's not to say that what you originally did is wrong, but I think the grader is looking for output in particular format, otherwise it won't let you pass.

Jessica H
Jessica H
16,612 Points

I"m not sure. Its been a few days since I did it but I passed with:

<?php $name = "mike"; ?>

<p><?php echo $name; ?></p>

Of course, this is not working anymore since I just tried it again.

Jessica H
Jessica H
16,612 Points

Oh sorry. My code isn't showing up. And I dont know how to use this discussion board well.

but I thought I used 'p' tags and semi colons.

I passed now with William Li's code.

Lucille daCosta
Lucille daCosta
2,286 Points

Thanks. I'll try again--I think the checker is acting strange!

Andrew Rady
Andrew Rady
20,880 Points

Hey Lucille,

If you were writing for a normal html page the code would work (Just tested it!) but in the challenge I think they want you to just use php and not mixing it with html. I just echoed the variable out with an echo in the php tags like so

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

and it worked!