PHP PHP Basics Daily Exercise Program String Manipulation

Cameron Leavitt
Cameron Leavitt
3,651 Points

1) Use the $fullName variable 2) Display the following string to the screen. Rasmus Lerdorf was the original creator

This is what I used and I get the correct output but it gives me an error saying the fullName has to be Rasmus Lerdorf.

index.php
<?php

//Place your code below this comment
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullName = "$firstName " . "$lastName ";
$fullName .= 'was the original creator of PHP.';
$fullName .= "\n";
echo $fullName;
?>

2 Answers

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,333 Points

There is a note: Important: In each task of this code challenge, the code you write should be added to the code from the previous task.

Each step the checker will check all tasks. You have updated $fullName in task 3 so it no longer passes task 2. For task 3 you should be able to echo the string that includes the $fullName variable without updating $fullName.

jonathanbarrios
STAFF
jonathanbarrios
Treehouse Teacher

👋 Cameron Leavitt,

You are very close!

Using your code at Challenge Task 2 of 3, I get the following error: Bummer: $fullName should equal Rasmus Lerdorf and this is because the $fullName variable should only return Rasmus Lerdorf. You code is using $fullName to echo the WHOLE sentence and this is where the problem lies. I echo the WHOLE sentence using double quotes without using $fullName .= and it passed:

<?php
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullName = "$firstName $lastName"; // 👈 No concatenation symbol `.` needed with double quotes

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

Happy coding 🙌