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 trialTolu Adesina
1,549 PointsI have a problem with my challenge on concatenating strings..
Use the $fullname variable to display the following string to the screen. Use an escape character to add a newline to the end of the string. 'Rasmus Lerdorf was the original creator of PHP'
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
//$fullname = $firstName .' '. $lastName;
$fullname = "'" . $firstName .' '. $lastName . ' was the original creator of PHP\'' . "\n";
echo $fullname;
?>
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! You're really close. What if I added this little tidbit to the instructions: "without changing the previous value of $fullname"? The problem here is that you're changing the value of $fullname from what passed in step 2.
Try echoing your new string directly with something like echo "My uncle is named $fullname";
Hope this helps, but let me know if you're still stuck!
Benjamen King
18,959 PointsI think you are taking the instructions too literally. Try:
$fullname = $firstName .' '. $lastName . ' was the original creator of PHP'."\n";
echo $fullname;
In other words, no single quotes. By the way, this works too:
$fullname = "$firstName $lastName was the original creator of PHP\n";
echo $fullname;
Jennifer Nordell
Treehouse TeacherUnfortunately, this code will also not pass the challenge as it overwrites the original value of $fullname as indicated in my answer above. The original value of $fullname must be left intact and unaltered for the challenge to pass
Tolu Adesina
1,549 PointsTolu Adesina
1,549 PointsThanks but i am still stuck, system keeps telling me "Oops! It looks like Task 2 is no longer passing."
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherWell here we go then! The two main problems here are that you are
Take a look:
Here you can see that I left the $fullname variable set to the full name of Rasmus Lerdorf. You were changing $fullname to be equal to "Rasmus Lerdorf was the original creator of PHP.\n". And his full name isn't that long! It sounds mildly like the Artist formerly Known as Prince
Then we echo out the $fullname and the string given by the challenge instructions. We do this directly in the echo so as not to replace the original value of $fullname. Hope that clarifies things!
Tolu Adesina
1,549 PointsTolu Adesina
1,549 PointsThank you very much, it worked... very grateful. Now i can move on..