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 trialBrane Opačič
6,686 PointsString manipulation: "\n" won't work!
When I run the code on a Workspace everything seems to be OK, but when I try and pass the Treehouse task number 3 it somehow fails?
Is it a specificity problem, am I overwriting my code?
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = "$firstName $lastName";
echo "$fullname\n is the original creator of PHP";
?>
3 Answers
andren
28,558 PointsIt's not a problem with your code, the problem is that you are not doing the exact thing that the challenge is asking, Treehouse challenges are often pretty strict about their requirements.
The task asks you to display: "Rasmus Lerdorf was the original creator of PHP" You typed "Rasmus Lerdorf is the original creator of PHP" they also asked for the newline to be added at the end of the string, not at the end of the variable name, so the string should be like this:
"$fullname was the original creator of PHP\n"
Brane Opačič
6,686 PointsI actually did manage to pass it a moment before your post, but a big thank you for your time and answer!
Nazmul Bhuiyan
880 PointsHello my code is correct but i am not passing. why?please help.
<?php
//Place your code below this comment $firstName = 'Rasmus'; $lastName = 'Lerdorf'; $fullname = $firstName .' '. $lastName echo "$fullname was the original creator of PHP\n"; ?>
andren
28,558 PointsNazmul Bhuiyan: You have fotgotten to end the third line of your code with a semicolon (;). If you add it like this:
<?php
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = $firstName .' '. $lastName; // A semicolon was missing on this line
echo "$fullname was the original creator of PHP\n";
?>
Then your code will pass.