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

Not outputting Mike according to the challenge...

I can't see what I'm doing wrong and why my output isn't "Mike'.

index.php
<?php

$name = "Mike";

?>

<?php echo $name ?>

2 Answers

Grace Kelly
Grace Kelly
33,990 Points

Hi Quinten, it seems you are missing a semi colan at the end of your echo statement, try this:

<?php echo $name; ?>
Placid Rodrigues
Placid Rodrigues
12,630 Points

This is not the problem here. This code can work perfectly here without the semicolon. Although a semicolon should always be there for different reasons. Check here: http://php.net/manual/en/language.basic-syntax.instruction-separation.php

On a second thought, the code challenge might require you to put in the semicolon.

Try putting everything into one php block:

<?php

$name = "Mike"; 
echo $name;
?>
Placid Rodrigues
Placid Rodrigues
12,630 Points

Although both suggestions by Grace Kelly and Tom Cawthorn are focused on better programming styles, I don't think any of the answers will solve the issue. I have tried Quintin's code exactly as he wrote it and I got perfect output. The problem is somewhere else.

I've just tried my code in the challenge and it passed.

What's the response you're getting back?