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

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Task 3 concatenation

Hi,

I have managed to get through the first two tasks of stage 3, but my code is not working.

What could be wrong?

Thanks!

concatenation.php
<?php

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



echo "The designer at Shirts 4 Mike shirts is named."".$fullName;

?>

3 Answers

<?php

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

echo "The designer at Shirts 4 Mike shirts is named" ." " .$fullName;

?>

echo "The Designer at Shirts 4 Mike is named:". " ".$fullName;

when concatenating you first to place the text in quotes like "put your text here" after the text use the concatenation (.) dot followed by a space in quotes again(so that there is space between your first string the other string/text) then after the space you add dot for concatenation with the variable $fullName (variable will not be in quotes) echo "string/text to be displayed"."space in quotes".$variable name;

Hi Juliette,

That's a great attempt! There are two issues I can see.

  • fullName needs to contain the concatenated names with spaces between each
  • the line being echo'd needs a space between the string and the fullName. This can be accomplished without concatenating an actual space by instead leaving a space at the end of the string.

Hope this helps!

Cheers

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Thanks Robert, but that is what I thought that I had done. It seems so simple, but I am still confused.

Maybe I should come back to this tomorrow with a fresh brain:-)

Breaks are good :) If you continue having issues tomorrow, just post in this thread and I'll be here to offer more thorough help.