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

Answer to Last Part of Objective

Can you please check my code to see why I am getting an error on the last step of this objective?

index.php
<?php

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

$newString = $fullname . ' was the original creator of PHP' . "\n";

  echo $newString;


?>

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Your code is functional. However, you've done something the challenge didn't intend for you to do. You've introduced an entirely new variable. If I remove that part and echo your string directly, it passes!

echo $fullname . ' was the original creator of PHP' . "\n";

So you need to remove the $newString variable. :bulb: It's always a good idea in challenges to try not to do anything the challenge doesn't explicitly ask for. Even if works beautifully, it can cause the challenge to fail.

Good luck! :sparkles:

Chris Adamson
Chris Adamson
132,143 Points

The extra newString variable isn't necessary:

<?php

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


?>

That makes sense. Thanks for the clarification, Jennifer and Chris. It's much appreciated.

-Neiv