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 trialJeen Xavier
1,086 PointsI dont understand why this is not correct echo "'$fullname was the orginal creator of PHP'\n";
I dont understand why this is not correct echo "'$fullname was the orginal creator of PHP'\n"; I dont understand why this is not correct I get the final output It doesn't seem to be right.
<?php
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = "$firstName $lastName ";
echo "'$fullname was the orginal creator of PHP'\n";
//Place your code below this comment
?>
2 Answers
tobiaskrause
9,160 Points<?php
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
// take the value of $firstname a whitespace and $lastName
$fullname = $firstName . " " . $lastName;
echo "'$fullname was the orginal creator of PHP'\n";
?>
You need to use string concatenation. Here the strings are the values of your two varaibles and a string with a withesprace.
Your $fullname = "$firstName $lastName "; does not work since the value of $fullname would be => "$firstName $lastName " since you mad the variable names to a string value with the ""
$fullname = "$firstName $lastName "; ===> "$firstName $lastName"
$fullname = $firstName . " " . $lastName; ===> "Rasmus Lerdorf"
Jason Anello
Courses Plus Student 94,610 PointsHi Jeen,
I'm not sure how you got passed task 2 here.
Your $fullname variable has 2 spaces in between the first and last name and also a trailing space at the end.
For the echo statement, the single quotes weren't meant to be part of the output so you would have to remove those. There's also a typo with orginal. It should be original.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsIn PHP, variables are evaluated if they're inside double quotes.
String concatenation isn't required here but you could solve it that way if you wanted to.