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

i'm having trouble with task 2: "Now echo Mike's Name To The Screen."

its saying that i am wrong but im copying it from the screen.

Hi, Isabelle! Can you post your code? Thanks. :smiley:

Steve Berrill
Steve Berrill
20,016 Points

Hi Isabelle,

Edit: As Dustin pointed out I need to explain to you why this is the answer. ill do my best :wink:

  • Set the variable $name
  • Assign it a string value "Mike"
  • Finish the line with a semi colon ;
  • Echo the variable name $name to print out the name
  • Make sure to add a ; at the end of this also, or it wont work.

Put it all together like this:

<?php

$name = "Mike";

echo $name;

?>

Hey Steve, Treehouse asks that when you provide an answer to a code challenge, you also provide an explanation. This way students are receiving benefit from the course material. If you could please edit your response to include why the answer you've provided is correct, that would be great. Thanks! :smiley:

Hi Steve,

When giving an answer to a question you should post it as an answer and not as a comment to the question. Please consider re-posting as an answer.

That's right, Steve Berrill, if you want to possibly receive credit, you'll have to post your response as an answer. :bowtie:

2 Answers

i wrote the same thing Steve Berrill but as soon as i refreshed the page and did it again it passed me. Thank you!

Steve Berrill
Steve Berrill
20,016 Points

thats great, glad I could comfirm it for u then :)

After refreshing the screen, this code finally passed:

<?php $name = 'Mike';

if( $name == 'Mike') { echo 'Hi, I am Mike';
} ?>

It's not exactly the same sentence ( missing a "!") but I don't care.