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

I dont understand why this is not correct echo "'$fullname was the orginal creator of PHP'\n";

I dont understand why this is not correct echo "'$fullname was the orginal creator of PHP'\n"; I dont understand why this is not correct I get the final output It doesn't seem to be right.

index.php
<?php
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = "$firstName  $lastName ";
echo "'$fullname was the orginal creator of PHP'\n";

//Place your code below this comment

?>

2 Answers

<?php
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
// take the value of $firstname a whitespace and $lastName
$fullname = $firstName . " " .  $lastName;
echo "'$fullname was the orginal creator of PHP'\n";


?>

You need to use string concatenation. Here the strings are the values of your two varaibles and a string with a withesprace.

Your $fullname = "$firstName $lastName "; does not work since the value of $fullname would be => "$firstName $lastName " since you mad the variable names to a string value with the ""

$fullname = "$firstName $lastName "; ===> "$firstName $lastName"

$fullname = $firstName . " " . $lastName; ===> "Rasmus Lerdorf"

In PHP, variables are evaluated if they're inside double quotes.

String concatenation isn't required here but you could solve it that way if you wanted to.

Hi Jeen,

I'm not sure how you got passed task 2 here.

Your $fullname variable has 2 spaces in between the first and last name and also a trailing space at the end.

For the echo statement, the single quotes weren't meant to be part of the output so you would have to remove those. There's also a typo with orginal. It should be original.