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

Aswer to tast 3 of 3

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".'was the original creator of PHP. \n';
echo $fullName;


?>

1 Answer

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

Hi there! While your code would produce close to the results needed to pass the challenge, it does it by altering the value stored in $fullName. Also note, that your code would result in "was the original creator of PHP" pushed right up against Rasmus Lerdorf as you have forgotten to account for a space.

In Step 2 you assigned "Rasmus Lerdorf" to $fullName. Now, $fullname contains the value "Rasmus Lerdorfwas the original creator of PHP \n". You've changed his full name to be that entire string, which is not what we're after. Instead, try echoing out the $fullName and that string directly in the same line. The easiest way to do this is to use double quotes to expand the value of the variable. Here's an example of what I mean:

$name = "Joao";

echo "Hi there, $name";

In my example I used the name variable inside of double quotes so that it expands the value. "Hi there, Joao" will be echoed to the screen.

Hope this helps! :sparkles:

Thanks it helped me