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 trialEvan MacAlpine
7,173 PointsProblem with task 3 of 3
Have tried a number of different solutions but can't figure it out. I get the error message "You have not displayed the correct string", even though When I run the code in the workspace it appears to be correct.
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = "$firstName $lastName";
echo "$fullname was the original creator of PHP\n";
?>
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Evan,
You code is 100% correct. I copied and pasted it into the challenge and all 3 tasks passed. It may have just been a glitch or something in the code checker.
Just copy your own code snippet from above and paste it into a fresh challenge window.
Keep Coding! :)
Evan MacAlpine
7,173 PointsIt looks like they had a specific method of concatenating in mind for the solution. This code works:
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = $firstName . ' ' . $lastName;
echo($fullname . ' was the original creator of PHP' . "\n");
?>
Jason Anders
Treehouse Moderator 145,860 PointsHey Evan MacAlpine, While both snippets are correct, your original code is cleaner (DRYer) and way more easy to read. Both will pass the Challenge, but I would stick with the original. :)
Evan MacAlpine
7,173 PointsThanks Jason Anders . Really appreciate your feedback!
Alexander Davison
65,469 PointsTry getting rid of the extra newline (\n) at the end of the last string.
Good luck, Alex
Jason Anders
Treehouse Moderator 145,860 PointsHey Alexander,
The \n
is explicitly asked for by the challenge instructions, so it needs to be there. :)
Alexander Davison
65,469 PointsOh ok :) cool
About a week ago I already passed the challenge I'm not sure why it isn't working (for two people!) so far...
Good luck, Alex
Maesai Prabhasavat
4,872 PointsMaesai Prabhasavat
4,872 PointsI use the same code it also doesn't work.