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 trialdaniel Couzens
4,759 PointsTask 3 combining strings
What is wrong with this code?
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullName = '".$firstName $lastName." was the original creator of PHP.'"\n";
echo fullName;
?>
1 Answer
dwayne chomyk
Courses Plus Student 8,719 Points<?php
//Place your code below this comment - not working for some strang reason $firstName = "Rasmus"; $lastName = " Lerdorf "; $fullName = $firstName." ".$lastName;
echo $fullName . " was the original creator of PHP. \n"; ?>
David Bilson
13,819 PointsDavid Bilson
13,819 PointsA few errors for you to correct to get this to work. I will not give you the answers directly, but will give you steps to complete the task.
Step 2 seems to be where you are struggling:
"Create a third string named 'fullName' that combines the $firstName and $lastName variable to make the string "Rasmus Lerdorf".
You need to create a 3rd variable $fullName (place it directly underneath the variables $firstName and $lastName).
// $fullName = $firstName and $lastName variables concatanted together with a space in between the words.
//Your final sentence should read:
<?php echo $fullName . " was the original creator of PHP. \n"; ?>
Notice how I have concatanated (joined together) the variable $fullName with the string " was the orginal creator of PHP. \n".
The variable and string are joined together using the dot or period.
Also notice that there is a space between the quote and the start of the string, otherwise i'd end up with:
Rasmus Lerdorfwas the original creator of PHP.
I hope this helps you work it out.