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

Nicholas Chetto
Nicholas Chetto
4,221 Points

Can someone help me with this I'm stumped. Thank you.

1) Use the $fullName variable 2) Display the following string to the screen. Rasmus Lerdorf was the original creator of PHP. 3) Use an escape character to add a newline to the end of the string.

index.php
<?php

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

$fullName .= $firstName . " " . $lastName;
"$fullName  was the original creator of PHP.\n";
?>

1 Answer

Shayne Laufenberg
Shayne Laufenberg
4,213 Points

Hey there Nicholas I see your having problems so i'll try to help you the best I can. Taking a look at your code I see you properly declared $firstName and $lastName setting them each equal to the data that was asked. However here:

$fullName .= $firstName . " " . $lastName;

In the task it wants you to set the variable equal to the contents it provided. In your current code you are trying to add a string to a variable that hasn't been declared yet. Use this:

$fullName = $firstName . " " . $lastName;

Another problem with your code is that you didn't display, or store the result as shown here:

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

So its almost like having something inside your memory that you will never remember. I've posted a full solution below hopefully by taking a look at that it should help you get past this.

Good luck!

Solution:

<?php

// Users First Name //
$firstName = "Rasmus";

// Users Last Name //
$lastName = "Lerdorf";

// Users Full Name //
$fullName = $firstName . " " . $lastName;

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

?>