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

Yu-Che Hung
PLUS
Yu-Che Hung
Courses Plus Student 10,607 Points

got confused don't know why it keep telling me that the task 2 no longer passed.

got confused don't know why it keep telling me that the task 2 no longer passed.

index.php
<?php

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

2 Answers

The fault lies in the line

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

Here, the first issue is that you are actually changing the original $fullname string, also you're forgetting the leading whitespace character before "was" . Secondly, you have an erroneous " that trails PHP. The last issue is that you never actually display (echo) anything.

You can fix it by changing the line to

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

You should note, however, that the final concatenation of the "\n" doesn't need to happen. You can just add \n inside your string to achieve the same effect.

Yu-Che Hung
Yu-Che Hung
Courses Plus Student 10,607 Points

still the same it keep telling me that the task 2 no longer passed.

Yu-Che Hung
Yu-Che Hung
Courses Plus Student 10,607 Points

I solved it. We have to create a new variable to store ' was the original creator of PHP" so that we won't change $firstName $lastName $fullname, then echo them out. thnank you mike!

Yen Wei Liu - The fault was mine. In my solution, I hurriedly typed an = rather than a + (they're on the same key, I guess I didn't shift fast enough). I've updated my answer to fix it. Glad that you sorted it out, though.

Michele Krieg
Michele Krieg
491 Points

This still didn't work for me either and I'm getting very frustrated. I typed it out in the workspace and it echoed perfectly. With so many ways to do it, why do you pick the most obscure one?? This is no way to learn. I'm done.

Yu-Che Hung
Yu-Che Hung
Courses Plus Student 10,607 Points

Michele Krieg: where did you stuck with? may I help you?