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 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
231,198 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
231,198 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