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 trialPeter Mayer
3,034 Pointsconcatenation php Code Challenge
Hey guys, I'm currently busy with the php challenge: http://teamtreehouse.com/library/programming/build-a-simple-php-application/adding-a-contact-form/concatentation
I don't know what I'm doing "wrong" and would really like to know that :-) Any ideas?
This is the task: 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.
This is the error Message: Bummer! $fullName is set, but it's not the concatenation of $firstName, $middleName, and $lastName with spaces between them.
That's my code: <?php
$firstName = "Mike"; $middleName = "the"; $lastName = "Frog"; $fullName =""; $fullName = "$firstName " . "$middleName " . "$lastName ";
echo "The designer at Shirts 4 Mike shirts is named ____";
?>
9 Answers
James White
6,159 PointsAlmost. That concatenates the names but doesn't add the space. You have to add a " " in between the names.
$firstName . " " . $middleName . " " . $lastName;
Charmaine Wallace
22,276 PointsAnd one year later I found this. About to pull my eyeballs out in frustration, I discovered that I did not have an actual space between the quotation marks, hence it kept telling me that there was no space concatenated between the variables. o_0
James White
6,159 PointsYou don't need double quotes around your variables.
Make $firstName . " " . $middleName . " " . $lastName;
kobi arami
Courses Plus Student 2,645 Points$fullName = $firstName ." ". $middleName ." ". $lastName;
kobi arami
Peter Mayer
3,034 Pointshey James, thanks for for your reply. you mean like that? <?php
$firstName = "Mike"; $middleName = "the"; $lastName = "Frog"; $fullName =""; $fullName = $firstName . $middleName . $lastName ;
echo "The designer at Shirts 4 Mike shirts is named ____";
?>
Brian Fennel
3,325 PointsAll I can say is wow how did i miss that.
Sam Lozier
9,699 PointsWeird i've entered the proper code and when I hit preview, I get the desired output, but it won't check out. After reloading the page and re-starting the challenge, it works fine.
Charmaine Wallace
22,276 PointsThat's happened to me Sam. Although most of the time not paying attention is to blame. HTML is very forgiving, PHP not so much!
Estevan Montoya
Courses Plus Student 23,989 PointsI had this:
$fullName = $firstname . " " . $middleName . " " . $lastName;
Does anyone see my mistake? It took me a while to figure out "name" was not capitalized in $first...