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

Challenge task 3 of 3 for php basics

Im being asked to use 2 variables, $firstName and $lastName. Im being asked to concatenate these 2 variables onto a $fullName variable and then contactenate a string on to that. My code is below.

It compiles just fine on my local php dev setup, but not on the teamtreehouse compiler.

Can someone explain what Im doing wrong?

index.php
<?php

//Place your code ow this commen

$firstName = 'Rasmus';
$lastName = 'Lerdorf';

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

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

echo $fullName;




?>

3 Answers

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

Hi there! It's important to note when doing these challenges to try not to do anything that they don't explicitly ask for. The value stored in $fullname should be the concatenation of the first name and the last name, which you did splendidly!. But then you went on to further alter the variable to contain the value of the first name and the last name and a bit about how he is the original creator of PHP.

Imagine that I added this instruction: do this without changing the value stored in $fullname.

Hint: this is a great place to use double quotes to unwrap the value held in fullname.

I think you can get it with these hints, but let me know if you're still stuck! :sparkles:

Jacob Anderson
Jacob Anderson
7,888 Points

I can't figure it out... What would be the code that I would have to put for the last step? I've been stuck for about an hour and a half.

Great, worked very well, thanks!

Jeremy Antoine
Jeremy Antoine
15,785 Points

Another hint. It doesn't say you cannot create another variable to display the string. This will prevent you from changing the value of the $fullname variable.