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

Ashley Newton
Ashley Newton
2,225 Points

To echo Mike's name to the screen I have written <?php echo $name ?> but can't move forward through this challenge

I have compared my code with the code I wrote in Workspaces, but I don't see what I am doing wrong. I am getting the message that says the code I've written is incorrect, but I'm not getting any more feedback explaining why. Can you help me to understand what I'm doing wrong?

index.php
<?php

$name = "Mike";

?>

<html>
<body>
  <section>
<p>
<?php echo $name ?>
  </p>
  </section>
</body>
</html>

1 Answer

Hi, Just gone back through the challenge and what worked for me was to do it all inside one php statement. For example:

<?php $name = 'Mike';

echo $name; 

?>

I think it might be getting confused with all the extra markup and 2 sets of php tags. Your code is fine though and should work in a real-world scenario.

Hope this helps :)