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

Monica Munteanu
Monica Munteanu
11,971 Points

I keep getting two errors that Task 1 or Task 2 are no longer complete, however I have not changed the code.

no details. I do not understand the errors I am getting

index.php
<?php

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

2 Answers

Patrik Horváth
Patrik Horváth
11,097 Points

good but next time Combine strings by "."

$value  = $newValue1 . $newValue2 . "STRING value";

it should be :

<?php

//Place your code below this comment
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullName = $firstName. " " .$lastName;
echo $fullName;
?>
Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

It's not required to use concatination if using double quotes.

<?php
$firstName = "Rasmus";
$lastName = "Lerdorf";

// will print "Rasmus Lerdorf"
$fullName = $firstName . " " . $lastName;

// will print "Rasmus Lerdorf"
$fullName = "$firstName $lastName";
Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

You are giving the variable $fullName a new value by using the equal sign.

Instead of doing that second assignment of $fullName you should instead echo out the value of $fullName + "was the original creator of PHP.\n" - like this:

<?php

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