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 trialKelly Carpenter
2,185 PointsHow do you create a new lined using \n in a string, and still have multiple tasks run individually?
I am able to get the string to output what it needs to say --- but I am getting a message saying that my second task is no longer running. I think I am placing the escape character \n in the incorrect place or with inproper syntax.
How do I go about getting a string to out put the proper information while still allowing previous tasks to run?
<?php
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = $firstName . ' ' . $lastName . ' was the original creator of PHP';
echo $fullname
//Place your code below this comment
?>
2 Answers
Thomas Fildes
22,687 PointsHi Kelly,
This challenge is a real handful sometimes basically you need to echo the fullname variable with strings concatenated together to create the required sentence. Here is the correct code below:
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullname = $firstName . " " . $lastName;
echo $fullname . " was the original creator of PHP" . "\n";
If you concatenate the string 'was the creator...' to the fullname variable you achieve the sentence. Also, I have concatenated the "\n" in a string as required which creates a new line.
Hope this helps. Happy Coding!
Tanja Schmidt
11,798 PointsThe hints in the error messages are often a bit confusing. Your previous code still runs, but it causes this specific error message because you've changed the value of the variable $fullname - I had the same problem at first. ;-) In this task you are just asked to use (and not to change!) $fullname to print the string to the screen. So reset your code and echo a string that includes $fullname and remember to add the line break right after PHP with no space in between. (And enter your code below the comment - placing it above might also cause an error in the challenge though the code itself runs fine).
echo "$fullname was the original creator of PHP\n";
Kelly Carpenter
2,185 PointsThank you so much! Very helpful.
Kelly Carpenter
2,185 PointsKelly Carpenter
2,185 Pointsthank you very much!