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

PHP Basics: String Manipulation - 3 Objectives

Challenge 1 asks for 2 variable with values of 'Rasmus' and 'Lerdorf'.

Challenge 2 asks for these strings to be combined in a third string, to create "Rasmus Lerdorf". Here is my code:

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

However this comes up as incorrect with the following message:

Bummer! $fullName should equal Rasmus Lerdof

Is the problem the fact that 'Lerdorf' now needs to be changed to 'Lerdof', and if so this then creates a problme with 'Task 1'.

Any advice or a way to get around this?

index.php
<?php

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

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

?>

1 Answer

andren
andren
28,558 Points

The issue is that you append quote marks at the start and end of the name which are not necessary. If you just combine $firstName and $lastName with a space between them like this:

<?php
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullName = $firstName . ' ' . $lastName;
?>

Then your code will work.