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

I am stuck on Build a Simple PHP Application Challenge Task 2 of 4

I am stuck?

concatenation.php
<?php

$fullName . "Mike";
$middleName = "the";
$lastName ="Frog";
$fullName = . $fullName . $middleName . $lastName;

echo $fullName;
?>

4 Answers

Hi Tim,

Try this,

<?php

$fullName . "Mike";
$middleName = "the";
$lastName ="Frog";
$fullName =  $fullName . " ". $middleName  . " ".  $lastName;

echo $fullName;
?>

You can also do as follow ;

<?php

$fullName . "Mike";
$middleName = "the";
$lastName ="Frog";
$fullName =  $fullName ," ", $middleName, " ",$lastName;

echo $fullName;
?>

comma or dot i.e. (. or ,) serve the same purpose of concatenation. But if you don't include a space then the out put will be as follow, firstnameMiddleNameLastName However by including the space you get firstName middleName lastName

hope that helps and do rate the answer if it is acceptable. cheers and all the best

Ok I will thanks Tim

yes this worked

<?php

$firstName = "Mike"; $middleName = "the"; $lastName = "Frog"; $fullName = $firstName . " ". $middleName . " ". $lastName;

echo $fullName; ?>

Remove the four underscores in the echo command and concatenate the remaining text with the variable $fullName.

<?php

$firstName = "Mike"; $middleName = "the"; $lastName = "Frog"; $fullName = $firstName . " ". $middleName . " ". $lastName;

echo $fullName; ?>