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

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,411 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,411 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.