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 trialThomas Barkel
Courses Plus Student 7,222 Pointsconcatenating variables
I'm unsure why i'm being told in the quiz that $fullName is not properly concatenated. Can someone advise?
<?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
231,269 PointsThe 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
Courses Plus Student 7,222 Pointshow are the spaces that are between the periods insufficient for creating "spaces in between"?
Steven Parker
231,269 PointsThose 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
Treehouse Project ReviewerIf 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