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 trialRonald Fombe
784 Points"Oops! It looks like Task 2 is no longer passing."??? But the output is working fine???
iy
<?php
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullname = "$firstName $lastName";
$fullname.=' was the original creator of PHP';
$fullname.= "\n";
echo $fullname;
?>
3 Answers
Jennifer Nordell
Treehouse TeacherHi there, Ronald! The problem here and the reason that it says that task #2 is no longer passing is that it no longer meets the requirements specified by the challenge. The variable $fullname is supposed to contain the combination of the first name and the last name. However, when you do this:
$fullname.=' was the original creator of PHP';
$fullname.= "\n";
you are overwriting the value stored in $fullname. So $fullname no longer contains just the first name and the last name but rather the entire string to be echoed. The results are very much the same, but the $fullname variable now contains the incorrect string.
It's important in these challenges to try not to do anything they don't explicitly ask for such as replacing the value of a variable or sometimes even creating new variables on your own.
Hope this helps!
edited for accuracy
Here is Brian's code corrected so that it passes the challenge using concatenation:
echo $fullname . ' was the original creator of PHP' . "\n";
A more elegant solution that doesn't require concatenation (as concatenation is not explicitly required) might be:
echo "$fullname was the original creator of PHP\n";
Brian Jensen
Treehouse StaffThis is a case of the work check engines silliness striking again! So frustrating when it does this!
<?php
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullname = "$firstName $lastName";
echo $fullname = ' was the original creator of PHP' . "\n"; // it wants this style of concatenation even though your way was 100% valid
?>
Ronald Fombe
784 PointsThank you Brian. You guys have no idea how much this thing was driving me nuts. I kept staring at it and it kept glaring right back at me yet not making sense. Thank you once again.
Brian Jensen
Treehouse StaffERMAHGERD so epic! Thank you Jennifer Nordell!
Brian Jensen
Treehouse StaffBrian Jensen
Treehouse StaffAwesome explanation! How do you get the little icons in there?
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherBrian Jensen thanks! The emoji are added in much the same way they are done in GitHub and #slack. You can find an emoji cheatsheet here. Also, at the bottom of the "Add an Answer" section is a Markdown Cheatsheet link that will show you some additional formatting tools used in posting answers.
Ronald Fombe
784 PointsRonald Fombe
784 PointsWow, thank you SO much! That really is a very simple and comprehensive answer. I appreciate it. Thank you Jennifer.