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

Hannah Schauer
Hannah Schauer
1,137 Points

How to add additional words to variable

In order to say "was the original creator of PHP" I had to add another variable because if I just put $fullName = $fullName . 'was the creator of PHP' . '\n'; it says it's wrong.

index.php
<?php

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

1 Answer

Benjamin Larson
Benjamin Larson
34,055 Points

Hi Hannah -

While there are often many ways of accomplishing a given task, these code challenges are often more specific about the way in which you need to solve them. So because the challenge says Use the $fullName variable to display the string, it's not going to pass when outputting your $answer3 variable, even if it contains the correct string.

However, that is not the main issue with your code. If you read my answer on your previous thread https://teamtreehouse.com/community/says-i-forgot-to-add-a-space-between-first-and-last-name, the problem is that you are using this operator:

.=

instead of:

=

For more information, about the difference, you can check my answer on the link to your previous question, or the PHP Manual: String Operators.