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 trialBrian Patterson
19,588 PointsNot sure why it is not passing.
Not sure why this does not work.
<?php
//Place your code below this comment
$firstName = "Rasmus";
$firstName = "Lerdorf";
$fullname = '$firstName $firstName';
?>
2 Answers
Alexander Davison
65,469 PointsThere's supposed to be only one space between the $firstName
and $lastName
in the final $fullName
string. However, you put three spaces. Since Challenges are super picky, you must remove two of the spaces.
~Alex
If this answered your question, please provide a "Best Answer". Thank you!
-- --
12,382 PointsHi Brian,
It does not pass because you are supposed to create two different variables - $firstName
, with the value of "Rasmus", and $lastName
, with the value of "Lerdorf". You created two of the same variable in the code you provided.
Then, you should create the variable $fullname
and store both $firstName
and $lastName
in it in a way that, if you'd echo $fullname
, it would display "Rasmus Lerdorf".
To do this, you have to concatenate. Below, you can see how that's done.
$fullname = $firstName . " " . $lastName;
I placed the full stops to concatenate $firstName
and $lastName
. The space between the two quotation marks (making that bit a string) is the space that needs to be displayed between "Rasmus" and "Lerdorf".
I hope this helps! :)
Alexander Davison
65,469 PointsActually, you can put variable names in strings, as long as the string is using double quotes. Your way does work, but Brain's way also works. He just put too many spaces between the two variables in the string.
Brian Patterson
19,588 PointsBrian Patterson
19,588 Points$fullname = $firstName $lastName; I have put this and it is still not passing.
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsYou still need the quotes. It should look like this:
$fullname = "$firstName $firstName";
Good luck! ~Alex