Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,521 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.