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 trialKarl Lindsay
908 PointsPHP 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
David Tonge
Courses Plus Student 45,640 PointsThe problem was the p tags because this passes even with the real world suggestion that @andrewshook made
<?php $name = "Mike";
echo $name
?>
Andrew Shook
31,709 PointsKarl, 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".
Karl Lindsay
908 PointsThanks Andrew! I thought I had tried it. Just tried again and formatted it differently and got through. Cheers!
Andrew Shook
31,709 PointsAndrew Shook
31,709 PointsIt very well could be the p tags, sometimes the code challenges can be very finicky.
Karl Lindsay
908 PointsKarl Lindsay
908 PointsOkay. Thanks David!
Awesome to get a bunch of answers so quickly!
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsIt 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:
Of course, if you have 2 consecutive php statements then it's preferable to put them in the same code block as David did.