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

$fullName .= " was the original creator of PHP.\n"; echo $fullName; this prints it out right but still not passing.

Why is this considered not passing for condition 2?

index.php
<?php

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

3 Answers

Hey buddy,

you can just try the simple version :

<?php

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

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

Thanks, Ameer, I was losing it cause it showed the same output but it makes sense that you wouldn't want the whole string saved in $fullName.

Rich Donnellan
MOD
Rich Donnellan
Treehouse Moderator 27,671 Points

You can also concatenate $fullName like so:

$fullName = "$firstName $lastName";

It's much easier to read/write, IMO. This works because anything inside of double quotes (") gets evaluated in PHP. I'd also recommend using single quotes (') for your variables unless you do intend to evaluate something.

The echo statement wouldn't need to be modified (sans leading space however).

Thanks, I didn't think about that.