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

Matthew Frost
Matthew Frost
9,855 Points

Why is this PHP Basics challenge failing?

I must be missing something, but when I am getting an error to say that Task 2 is no longer passing. I have tried re-writing the code for Task 2 in multiple ways and it passes that task, but then I cannot get Task 3 to pass. What am I doing wrong?

index.php
<?php

//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';

$fullName = "$firstName $lastName";

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

echo $fullName;

?>

1 Answer

andren
andren
28,558 Points

The issue is that in Task 2 you are asked to set $fullname to "$firstName $lastName", in task 3 you change the contents of $fullname by adding " was the original creator of PHP.\n" to it. This breaks task 2 because $fullname now contains something besides just "$firstName $lastName".

In task 3 you are not supposed to change the $fullname variable at all, you are just meant to use it as you echo out the sentence. Like this:

<?php

//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';

$fullName = "$firstName $lastName";

echo "$fullName was the original creator of PHP.\n";
?>
Matthew Frost
Matthew Frost
9,855 Points

Ah I see. Thanks so much!