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

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,110 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";
?>