Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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