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 Build a Simple PHP Application Adding a Contact Form Concatentation

Anything wrong with these codes below. $fullName = $firstName . "\n" . $midleName . "\n" . $lastName;

Anything wrong with these codes below. I was told to put spaces among those variables, but it doesn't go thru.

$fullName = $firstName . "\n" . $midleName . "\n" . $lastName;

concatenation.php
<?php
$fullName = $firstName . "\n" . $midleName . "\n" . $lastName;
$lastName = "Frog";
$firstName = "Mike";
$middleName = "the";



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

?>

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Casey;

Welcome to Treehouse!

You just need spaces, not newline characters. Remove the \n references and you should be good. Also, you need to define the $fullName variable after the other variables. Until then it won't know what $firstName, $middleName, or $lastName are or are equal to. Your $fullName variable assignment would then look like:

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

Happy coding,

Ken

Thank you very much! I love the teamtreehouse!

Hi Casey,

You have the $fullName variable set before the other 3 which means it won't be able to take their values as they haven't been set yet.

I also noticed you're missing a 'd' from $middleName in the concatenation line.

Your line under the 3 variables would then look something like:

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

Hope that helps

-Rich

Thank you very much!

No problem, happy to help :)

-Rich