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 trialKevan Young
2,035 PointsChallenge Task 2 creating third string named $fullname
I am suppose to create a third sting called 'fullname' using $firstName and $lastName strings I have already created.
My code reads $fullname = "$firstName" + "lastName";
It is telling me I forgot to add a space between $firstName and $lastName. I have gone back and watched the videos, and changed the code several times and cannot figure out what I've done wrong. Please Help!!!
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = "$firstName" + "$lastName";
?>
1 Answer
Mikkel Rasmussen
31,772 PointsYou don't want to have quotes around your variables - quotes is for text like spaces.
In php we are also not using + to add two string together but just one dot if we don't need any space or text between our two variables.
$fullname = $firstName ." ". $lastName;
Kevan Young
2,035 PointsKevan Young
2,035 PointsPerfect!! Thanks Mikel!