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

Luis Joa
Luis Joa
4,597 Points

What's wrong with this? (PHP)

The task say:

"Now echo Mike's Name To The Screen."

I don't know how make well the challenge.

index.php
<?php

$name = "Mike";

?>

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

4 Answers

Andrew McCormick
Andrew McCormick
17,730 Points

yeah, it just wants it in the same php block.

Luis Joa
Luis Joa
4,597 Points

Thank you! for your answer. Now I know the correct form, I'm sharing it for other students:

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

Avaronnan Abhinesh
Avaronnan Abhinesh
193 Points

Hi,

This is because you are using <title> tag. Title is shown in the Top of the browser - not in the browser. So, My answer is working - because u can see the title on top of the browse showing "Mike" You can change the tag to<h1> , then it will print "Mike" as heading......This time -- inside the browser :)

<?php

$name = "Mike";

?>

<h1><?php echo $name; ?></h1>
Avaronnan Abhinesh
Avaronnan Abhinesh
193 Points

put a semicolon after the echo $name . like -

<?php

$name = "Mike";

?>

<title><?php echo $name; ?></title>
Luis Joa
Luis Joa
4,597 Points

thanks! But it not working yet.

Sara Hardy
Sara Hardy
8,650 Points

Maybe the challenge wants you to echo it without the < title > tags.

Luis Joa
Luis Joa
4,597 Points

Thank you Sara for your answer. Now I know the correct form, I'm sharing it for other students:

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