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

"Oops! It looks like Task 2 is no longer passing."??? But the output is working fine???

iy

index.php
<?php
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullname = "$firstName $lastName";

$fullname.=' was the original creator of PHP';
$fullname.= "\n";

echo $fullname;

?>

3 Answers

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

Hi 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.

:bulb: 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! :sparkles:

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";
Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Brian Jensen thanks! :smiley: 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 :arrow_heading_down: of the "Add an Answer" section is a Markdown Cheatsheet link that will show you some additional formatting tools used in posting answers.

Wow, thank you SO much! That really is a very simple and comprehensive answer. I appreciate it. Thank you Jennifer.

Brian Jensen
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Brian Jensen
Treehouse Staff

This 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 
?>

Thank 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.