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

echo not working

This is a very simple code challenge but for some reason I can not get the answer to be accepted. The question is Now echo Mikes name using the variable

<?php

$name = "Mike";

?>

I tried these variations

/* option 1 / <?php echo $name ?> /*single line of code no ; needed/ /* option 2 */ Just tried adding <p></p> or <h1></h1. no luck on the quiz

what am I missing?

Jim

index.php
<?php

$name = "Mike";

?>  

<?php echo $name ?>

2 Answers

Hi Jim,

I believe this is due to your code not being in the same php code block (the challenges can get quite specific :) ). Currently you have them in two separate blocks. Can you try combining the two please? e.g.

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

-Rich

This worked, What is strange is that in the lesson all echo blocks were outside of the php code block

Thank you,

Jim

No problem :)

-Rich

Brenda Krafft
Brenda Krafft
18,036 Points

Wow! I am having this exact same problem, but even when I copy and paste the code in from above I still get an error saying "Bummer! I am not seeing the word "Mike" in the output. Did you echo something different?"

Here's the code:

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

Am I not seeing something obvious here?