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

Miguel Nunez
Miguel Nunez
3,266 Points

Create a third string named 'fullname' and use the $firstName and $lastName variable

Bummer! It looks like you forgot to add a space between the first and last name

$firstName = 'Rasmus'; $lastName = 'Lerdorf'; $fullname = $firstName . $lastName;

What i'm I doing wrong here?

index.php
<?php

//Place your code below this comment

?>
Ulan Assanoff
Ulan Assanoff
9,922 Points

Actually you need some space while joining two strings, something like this $fullName = $firstName .' '. $lastName;

you need to add space when concatenating your strings so it should be $firstName.' '.$lastName;

hassan alzahrani
hassan alzahrani
3,623 Points

You need to add space in between the names so the result instead of : RasmusLerdorf will be: Rasmus Lerdorf

As following: $fullname = $firstName . ' '.$lastName;

4 Answers

Gabor Gazdag
Gabor Gazdag
10,474 Points

Hi Miguel!

The solution would be: $firstName = 'Rasmus'; $lastName = 'Lerdorf'; $fullname = $firstName .' '.$lastName;

My suggestion would be to set all of your varibales in a new row, it makes your code more readable.

Cheers, Gabor

Miguel Nunez
Miguel Nunez
3,266 Points

Thanks guys all your answers helped out I need help with another one

Use the $fullname variable to display the following string to the screen. Use an escape character to add a newline to the end of the string. 'Rasmus Lerdorf was the original creator of PHP'

$firstName = 'Rasmus'; $lastName = 'Lerdorf'; $fullname = $firstName .' '.$lastName;

You need to concatenate the two variables by using a period inbetween them.

$fullName = $firstname . $lastName;

amisha prajapati
amisha prajapati
4,484 Points

$firstName='Rasmus'; $lastName='Lerdorf'; $fullname = $firstName. ' ' . $lastName;