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

PHP PHP Basics Daily Exercise Program String Manipulation

Cliff Jackson
Cliff Jackson
2,887 Points

Another challenge problem, trying to combine the first name and second name strings together...does not work?

another challenge and more wasted time....trying to make a full name string out of first and second name strings...any ideas?

index.php
<?php

//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';

$fullName = $firstName . $lastName;

?>

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing fine, but keep in mind that you've forgotten to accommodate for a space. The value now stored in $fullName will be "RasmusLerdorf" instead of "Rasmus Lerdorf". There are a couple of ways you can do this that will put a space between the two.

I think you can get it with this hint, but let me know if you're still stuck! :sparkles:

Cliff Jackson
Cliff Jackson
2,887 Points

when i try to put the space in it says task 1 is no longer valid and if i leave a space in task one it says the string is invalid

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Unfortunately, I'm not sure what you've tried. There are two ways to do this. The simplest (in my Γ³pinion) is to use the double quotes to expand the value of the variable in place.

$fullName = "$firstName $lastName";

Alternatively, you could use concatenation to insert a space like so:

$fullName = $firstName . " " . $lastName;

Hope this helps! :sparkles:

Cliff Jackson
Cliff Jackson
2,887 Points

I was trying concantenation but didn't need to do it that way, found the two strings in double quotation marks worked ok. Thanks for the help Jennifer