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
Dungaamaa Tudevdorj
8,815 PointsPHP concatenation
Create a variable called fullName and assign it a value equal to the concatenation of the firstName variable, a space, the middleName variable, a space, and the lastName variable.
I can not get answer
so far i tried $fullName=$fullName. $firstName $middleNAme $lastName; or $fullName=""; $fullName=$fullName.$firstName; $fullName=$fullName.$middleName; $fullName=$fullName.$lastName;
Not sure which part is wrong. Help!!
4 Answers
Steve McKinney
29,274 PointsI think the answer may be:
$fullName = $firstName . " " . $middleName . " " . $lastName;
Kevin Korte
28,149 PointsWe use a period '.' as the concatenation operator. This period must go in between every variable, and " "
We concatenate a space as a set of parenthesis with a space in them, like so " ".
You do not need to to set the variable $fullName equal to itself to start.
So $fullName must equal $firstName plus a space, then $middleName, and another space, and finally $lastName.
Does that help you put it together to pass this level?
James Barnett
39,199 PointsSteve McKinney - Here on the forum we try to give hints first (like Kevin Korte's excellent post) before just giving away the answer.
Remember the goal is help fellow Treehouse members understand the material not get them past a code challenge.
Dungaamaa Tudevdorj
8,815 PointsThank you all it helped lot