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

Martin Upson
Martin Upson
1,969 Points

How do I echo Mike's name to the screen? I don't really understand the meaning of this question.

Is this something I include as part of the h1 <?php echo $name ?></h1>

this doesn't work...

3 Answers

You didn't post your code, but the command is

echo $name;
Martin Upson
Martin Upson
1,969 Points

Thanks, Ted,

I'm trying this... <?php $name = "Mike" ?> <h1><?php echo $name ?></h1>

How would you write it?

Regards, Martin

Exactly as I did above. Just make sure you use the correct variable.

Sean Do
Sean Do
11,933 Points

Part 1 of the Code Challenge wants you to create a PHP block code since they don't give it at first.

<?php

?>

Try to memorize this, it's very important when implementing PHP into HTML code or using PHP in general. After this, create a variable and echo it, don't try to echo it with HTML tag even it's common to echo with HTML tag. For this specific challenge, they wants you just echo w/ PHP.

<?php
$name = "Mike";

echo $name;
?>
Martin Upson
Martin Upson
1,969 Points

thanks Sean and Ted. For some reason, it didn't include the code I'd written. I needed to create two separate php blocks, which I found out through much trial and error!

Thanks for your help.

Best regards, Martin