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 trialCasey Choi
540 PointsAnything wrong with these codes below. $fullName = $firstName . "\n" . $midleName . "\n" . $lastName;
Anything wrong with these codes below. I was told to put spaces among those variables, but it doesn't go thru.
$fullName = $firstName . "\n" . $midleName . "\n" . $lastName;
<?php
$fullName = $firstName . "\n" . $midleName . "\n" . $lastName;
$lastName = "Frog";
$firstName = "Mike";
$middleName = "the";
echo "The designer at Shirts 4 Mike shirts is named ____";
?>
2 Answers
Ken Alger
Treehouse TeacherCasey;
Welcome to Treehouse!
You just need spaces, not newline characters. Remove the \n
references and you should be good. Also, you need to define the $fullName
variable after the other variables. Until then it won't know what $firstName
, $middleName
, or $lastName
are or are equal to. Your $fullName
variable assignment would then look like:
$fullName = $firstName . ' ' . $middleName . ' ' . $lastName;
Happy coding,
Ken
Rich Bagley
25,869 PointsHi Casey,
You have the $fullName
variable set before the other 3 which means it won't be able to take their values as they haven't been set yet.
I also noticed you're missing a 'd' from $middleName
in the concatenation line.
Your line under the 3 variables would then look something like:
$fullName = $firstName . ' ' . $middleName . ' ' . $lastName;
Hope that helps
-Rich
Casey Choi
540 PointsThank you very much!
Rich Bagley
25,869 PointsNo problem, happy to help :)
-Rich
Casey Choi
540 PointsCasey Choi
540 PointsThank you very much! I love the teamtreehouse!