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


abdul faiz mohd jayramie eng
abdul faiz mohd jayramie eng
Courses Plus Student 4,478 Points

PHP forms..........1 hour past by without solution

Hmm....i wonder what was the error.

Question Was: "Create a variable called fullName and assign it a value equal to the concatenation of the firstName variable, a space, the middleName variable, a space, and the lastName variable."

My Final Answer:


$firstName = "Mike";

$middleName = "the";

$lastName = "Frog";

$fullName = $firstName ."\n";

$fullName = $fullName . $middleName ."\n";

$fullName = $fullName . $lastName;

echo $fullName;

echo "The designer at Shirts 4 Mike shirts is named ____";


I tested in the preview, it does appear to be "Mike the Frog" with a space in between. What was the error?

i also tried these method:

$fullName = $firstName . $middleName . $lastName;

also tried adding "\n" in between. all method fail.

4 Answers

Mike Croft
Mike Croft
7,463 Points

$fullName = $firstName . " " . $middleName . " " . $lastName;

This should work, you need to add the spaces as you can see above, hope this helps

abdul faiz mohd jayramie eng
abdul faiz mohd jayramie eng
Courses Plus Student 4,478 Points

i did tried that solution. i was not aware that space between them was sensitive case. the spaces for . " " . in the tutorial video was not so obvious. hope they'll fix this. Thanks btw. Merry Christmas!

Mark Flavin
Mark Flavin
10,199 Points

Not to further confuse matters but as long as you use double quotes ("") you can actually make the code a bit cleaner.

$fullName = "$firstName $middleName $lastName";

Randy Hoyt
Randy Hoyt
Treehouse Guest Teacher

It looks like the code you originally posted was all correct except for the "\n"; you just needed to replace each "\n" with a " ". The "\n" creates a line break (instead of a space), so your PHP variable actually had a value like this:


You are right that the preview is confusing! In the preview, it actually looked correct because the browser ignores the line breaks and displays it as a space. I think I'll modify the code challenge to display a more helpful message in that case.