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 Statements & Comments

Sultan Baig
PLUS
Sultan Baig
Courses Plus Student 18,002 Points

Code challenge on PHP basics

So, I'm trying to pass code challenge number two on PHP basics. First question passes, "Set variable name = to Mike. Code is <?php $name = "Mike"; ?>

Second question is echo name to screen. Code I am using is <?php echo $name; ?>

This is not passing.....error I get is "Mike is not in your output."

11 Answers

They are looking for it contained in the same code block...

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

For some reason, your echo and variable have to be in the same php tag, dont put the echo in a seperate block or it wont pass.

Chuck Powers
Chuck Powers
13,155 Points

Instructions need to be modified or the challenge does. the video and workspace focused on php blocks inside of the html, and I don't see how solving the challenge this way fails the provided instructions. Minor tweak. Just change the wording of the instructions or change the correct output.

You are so right - but until now nothing has changed in this challenge – this is annoying!

Jason Larkin
Jason Larkin
13,970 Points

I am having the same problem and this solution doesn't work for me. Can anyone help?

Can you copy and paste what you have? Might be slightly off.

Jason Larkin
Jason Larkin
13,970 Points

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

Why doesn't it work for me? Please help!

Not sure what browser you are using , but try the latest stable chrome. Or even restart your browser. It worked for me, just copying your code.

Jason Larkin
Jason Larkin
13,970 Points

Hi Dan, I'm using the latest version of Chrome. I don't know what it could be?

Did you try shutting chime completely down, and restarting. Many times for me FB running in the background will mess up the browser after long periods of time.

Jason Larkin
Jason Larkin
13,970 Points

Thank you Dan, I shut everything down but Chrome and it finally worked! Thanks again!

Mark Bradshaw
Mark Bradshaw
Courses Plus Student 7,658 Points

Thanks for this help. I was down to pulling out my last hair follicle. Cheers.

The above worked for me but I had to delete any blank lines below. It should be spread over 4 lines.

Robert Ramirez
Robert Ramirez
3,644 Points

Spreading the code over 4 lines as suggested by Matthew is best practice. It makes the code more readable and visually organized. When we do a variable assignment as in $name ="Mike"; that's all we are doing. If we want to output the code to he user's screen (browser), then we must either use the echo or print command. Hope this helps.