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 Daily Exercise Program String Manipulation

Problem 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.

index.php
<?php

//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = "$firstName $lastName";
echo "$fullname was the original creator of PHP\n";
?>

I use the same code it also doesn't work.

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey 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! :) :dizzy:

It 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
Jason Anders
Treehouse Moderator 145,860 Points

Hey 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. :)

Thanks Jason Anders . Really appreciate your feedback!

Try getting rid of the extra newline (\n) at the end of the last string.

Good luck, Alex

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Hey Alexander,

The \n is explicitly asked for by the challenge instructions, so it needs to be there. :)

Oh 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