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

Shehan Guruge
Shehan Guruge
6,828 Points

Task 3 of 3 What is considered correct ?

I have tried with the following code to pass this section I am presuming that it has been entered correctly as it gets displayed without an issue however upon clicking the check button I would get the following message "It looks like Task 2 is no longer parsing" What would be the work around or correct answer i need to give in this case ?

Cheers and thanks for feedback and comments

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;
?>

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Shehan,

Yes, while the code will provide the proper output, it is not how the challenge wants you to achieve it. Challenges are very specific and very picky when it comes to its instructions.

The second task wants you to create the fullname variable using the other two variables you created. Now remember that in PHP, if you enclose variables in double quotes, the value of the variables will be used and anything else inside of the quotes is taken as is. You have used concatenation to create the variable, which is correct and does work, but not what is asked.

So instead of concatenation, you will use double quotes and just the variable names.

$fullname = "$firstName $lastName";

The space between the two variables will be recognized and the output will be correct.

For the third task, you are to output to the screen the specific string the challenge is asking for. Here you are adding to your already created $fullname. This is not what the task asks for. It wants you to use the $fullname variable to create and out put the string.

Again, your code is correct and will output, but not the way it wants it done. Instead of adding to the variable and echoing the new variable, echo the actual string using the variable (very similar to the way you combined the two above). Remember, double quotes render the value of a variable...

Give it another go with this in mind. If you're still stuck, just leave a comment here. :)

Keep coding! :dizzy:

I checked and it's ok to do task 2 with concatenation.

Shehan Guruge
Shehan Guruge
6,828 Points

Hi Jason,

Thanks for the clarity. Worked like a charm.

Cheers!