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 trialWeronika Ryfka
885 PointsHow do I combine $firstName = 'Rasmus'; and $lastname = 'Lerdorf'; to make $fullName = Rasmus Lerdorf?
String Manipulation
2 Answers
Steven Parker
231,271 PointsJoining strings together is called "concatenation", which was explored in detail in the video on Combining Strings. You may want to review that video.
The operator symbol for concatenation is a period ("."). It essentially acts like "glue" sticking two strings together to make one longer one. You can combine as many as you want in a single statement, and they can be a mix of literals (things in quotes) and variables containing strings.
I'll bet you can get it now, without an explicit "spoiler".
Johnathan Shoff
6,877 Points<?php
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullName = $firstName.' '.$lastName;
?>
Exactly as Steven Parker mentioned, but figured I would provide a demonstration of how you would specifically concatenate strings in PHP.