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

Create a variable called fullName and assign it a value equal to the concatenation of the firstName variable, a space, t

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.

concatenation.php
<?php

$firstName = "Mike";
$middleName = "the";
$lastName = "Frog";
$fullname = 



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

?>

2 Answers

Chris Shaw
Chris Shaw
26,650 Points

Hi MUZ140770 Selestino Gama,

Concatenating strings in PHP is pretty simple, all it requires is for us to use a period and in the case of this challenge, two spaces joining three variables. For the challenge all we really need to do is use . ' ' . twice, once between $firstName and $middleName, and again between $middleName and $lastName.

See the below.

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

Happy coding!

thanks it worked

Hi Selestino,

Glad to hear that Chris Upjohn's answer worked. On the forums, when an answer solves your issue it is great for you to mark it as the Best Answer. This rewards the person who answered with some bonus points and also lets other forum members, who may be facing the same or similar issue, know that this thread has an approved answer. I've marked it for you this time around, but just something to keep in mind moving forward.