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

Sanjay Mistry
Sanjay Mistry
2,725 Points

Issue with: Challenge Task 2 of 2 Now echo Mike's Name To The Screen.

My answer is the following code, but it keeps saying it's not correct.

<body>

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

</body>

index.php
<?php

$name = "Mike";

?>

<body>

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

</body>

1 Answer

Alex Heil
Alex Heil
53,547 Points

hey Sanjay Mistry , actually your code in general looks good - just keep in mind to always end your php statements with a semicolon (even if it should still work in this case without one...).

however I guess the problem here is that you added a second code block (the html one) while the challenge might only check the first php block (that you added in task 1) and there the system can't find the echo statement.

so try to wrap the variable declaration and the echo statement in the first block and it should be fine, like this:

<?php

$name = "Mike";
echo $name;

?>

hope that helps and have a nice day ;)

Sanjay Mistry
Sanjay Mistry
2,725 Points

Hi Alex, Thanks for the prompt response.

The answer has been accepted.

Thanks Sanj