Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics (Retired) PHP Data & Structure PHP Variables

Annalyn Aguilar
PLUS
Annalyn Aguilar
Courses Plus Student 150 Points

<?php echo $name ?> Will print the name right? why it says BUMMER when I check my work?

PHP Basic

index.php
<?php

$name = "Mike";

?>
<?php echo $name ?>

2 Answers

Ryan Field
PLUS
Ryan Field
Courses Plus Student 21,240 Points

Hi, Annalyn. While what you have will work technically, the challenge wants you to put everything inside one php block. In addition, while you can omit semicolons for single-line blocks of PHP, it's always a good idea to include them so you don't run into errors if you decide to add on more code later.

Jeff Lemay
Jeff Lemay
14,266 Points

This challenge seems to come up every other day where people run into the same issue. Is it possible for Treehouse to add to the BUMMER saying "Make sure your code is in a single php block"?

Annalyn Aguilar
Annalyn Aguilar
Courses Plus Student 150 Points

I tried that one too. I tried all the things that I know. I'm sure it's a technical reason.

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 90,719 Points

Maybe someone can ask this in treehouse support. So we can get such a message on there. :-)

Ryan Field
Ryan Field
Courses Plus Student 21,240 Points

Jeff Lemay : I'm sure it would be possible from a technical perspective, but I don't work for Treehouse, so you'd have to contact support.

Annalyn Aguilar : I just tried the challenge, and it passes. You need to do something like this:

<?php

$name = "Mike";
echo $name;

?>
Annalyn Aguilar
Annalyn Aguilar
Courses Plus Student 150 Points

Yup. I also did that and it passed. That was right after I posted this q.

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 90,719 Points

I can't think of a reason based on what I've learned today. Seems odd.

Is it looking for a different variable name of a different string? The code challenges look for something very specific. :-)

Annalyn Aguilar
Annalyn Aguilar
Courses Plus Student 150 Points

Nope, my code is right. I tried many times like

<?php

$name - "MIke"; echo $namel

?>

I still get a Bummer result.

I tried it again after posting and I know that I am correct. Browser problem I guess or a bug on Treehouse. Thank you for your reply.

Jeff Lemay
Jeff Lemay
14,266 Points

This code is not correct. You used a dash to define the name variable instead of an equal sign and the echo statement is for "namel" instead of "name".

What you posted originally was correct, the challenge just wants you to use a single php block like Ryan suggested in the other answer.

Annalyn Aguilar
Annalyn Aguilar
Courses Plus Student 150 Points

Lol yeah, the second one is really wrong. That is not a copy and paste, I was typing so fast :)