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 Basic PHP Website (2018) Adding a Basic Form Concatenation

Thomas Barkel
PLUS
Thomas Barkel
Courses Plus Student 7,222 Points

concatenating variables

I'm unsure why i'm being told in the quiz that $fullName is not properly concatenated. Can someone advise?

index.php
<?php

$title = "Dr.";
$firstName = "David";
$lastName = "Bowman";
$fullName .= $title . $firstName . $lastName;



echo "The lead character from 2001: A Space Odyssey is named ____";

?>

3 Answers

Steven Parker
Steven Parker
210,472 Points

The error message contained a hint: "Bummer: Make sure $fullName is set to the concatenation of $title, $firstName, and $lastName, with spaces in between."

You're joining all the words, but you still need a couple of spaces to keep them all from running together. Also the assignment should be just a plain "=" (not ".=").

Thomas Barkel
PLUS
Thomas Barkel
Courses Plus Student 7,222 Points

how are the spaces that are between the periods insufficient for creating "spaces in between"?

Steven Parker
Steven Parker
210,472 Points

Those don't get added into the string. To get spaces into the string, they need to be literal strings (made by surrounding each space in quotes). Those can then be concatenated with extra periods. Example:

<?php
$bothWords = $firstWord . " " . $nextWord;
Amber Stevens
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Amber Stevens
Treehouse Project Reviewer

If you hit the 'Preview' button on the code challenge you'll see what it looks like and I think you'll be able to better see what the problem is