Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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; ?>