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

PHP Variables challenge broken?

I can't get it to echo 'Mike' Not sure what I've done wrong. Screenshot: http://cl.ly/image/3A113G2a2y3N

2 Answers

The problem was the p tags because this passes even with the real world suggestion that @andrewshook made

<?php $name = "Mike";
echo $name
?>
Andrew Shook
Andrew Shook
31,709 Points

It very well could be the p tags, sometimes the code challenges can be very finicky.

Okay. Thanks David!

Awesome to get a bunch of answers so quickly!

It was likely the p tags because that changes the output from what the challenge is expecting.

I was also going to say that it was the 2 separate php blocks because at one point in time this challenge didn't like 2 separate php blocks.

The following now passes though:

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

<?php
echo $name;
?>

Of course, if you have 2 consecutive php statements then it's preferable to put them in the same code block as David did.

Andrew Shook
Andrew Shook
31,709 Points

Karl, in the real world you don't have to use a semi-colon after a statement if the statement ends with the PHP closing tag ( ?>), but the code challenge my require you to use a semi-colon. Try placing a semi-colon at the end of "echo $name".

Thanks Andrew! I thought I had tried it. Just tried again and formatted it differently and got through. Cheers!