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 trialVictoria Loisi
7,070 PointsI'm doing what the challenge says and still I get it as incorrect: Displaying "Rasmus Lerdorf"
The challenge says: 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'
And I'm doing this:
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = "$firstName $lastName";
echo " '$fullname was the original creator of PHP' \n";
The last line is the new challenge, and the first three are from past challenges in the same series. I'm getting "Bummer! You have not displayed the correct string" But This code does display 'Rasmus Lerdorf was the original creator of PHP' and generates a new line at the end of the string.
I did try as well:
echo "$fullname was the original creator of PHP \n";
What am I doing wrong?
8 Answers
Daniel Gauthier
15,000 PointsHey Victoria,
The issue you're running into in the code you originally tried is the way you used your quotes.
In the second attempt, you added an unnecessary space between the PHP and \n.
Both sets of code listed below pass:
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = $firstName . ' ' . $lastName;
echo $fullname . " was the original creator of PHP" . "\n";
?>
Or you can achieve the same thing without concatenating the new line:
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = $firstName . ' ' . $lastName;
echo $fullname . " was the original creator of PHP\n";
?>
You were close though. Just remember that spaces inside of strings matter.
Good luck!
Daniel Gauthier
15,000 PointsAdding a little more clarification about that first attempt:
You wrapped the entire line in a set of double quotes in this line:
echo " '$fullname was the original creator of PHP' \n";
Which would seem to almost achieve what you were looking for, but would write out:
'Rasmus Lerdorf was the original creator of PHP'
Quotes included.
Since escape characters will not work unless they're encased in double quotes, you could also just use this code:
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullname = $firstName . ' ' . $lastName;
echo "$fullname was the original creator of PHP\n";
?>
I personally would recommend using concatenation operators while learning, just to get a feel for how they work, which is why I offered the first solution, but they all work.
Good luck with the course!
Harrinson Ariza
8,189 PointsThanks for your support! Your advice helped me with this quiz!
casthrademosthene
6,275 PointsCan you help me also, I'm following your directions and I keep getting this message ( Bummer! You have not displayed the correct string)..
Daniel Gauthier
15,000 PointsHey casthrademosthene,
Before you do anything, refresh the page with the challenge. There are times when the editor seems to get stuck in an error cycle and refreshing the page seems to clear it.
If you're struck on this question, both of the examples provided in this answer will pass. Just make sure that you either copy and paste them (bad habit to get into, but worthwhile at times to get past bumps when stuck while learning) in their entirety into the challenge.
Alternatively, you can also type the entire answer out while checking each character you type against the provided answer.
From the error you're receiving, it sounds like you have a typo somewhere in your code, so by checking what you're typing versus the answer provided, as you type it, you should be able to figure out where you were making the mistake.
Good luck with the course!
casthrademosthene
6,275 PointsThanks Daniel turns out I didn't have the single quotes around my $firstName and $lastName variable, it allowed for me to pass without it being in a single quote until I got to question 3. So thank you again, you were a big help ^_^
nathanielcusano
9,808 Pointsecho $fullname. " was the original creator of PHP" . "\n" ;
Rodrigo Herrera
1,189 PointsIts missing a "." at the end of PHP
<?php
//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';
$fullName = $firstName . ' ' . $lastName;
echo $fullName . " was the original creator of PHP.\n";
?>
Victoria Loisi
7,070 PointsThank you!!! And thank you for the recommendations as well.
Levi Donaldson
7,692 PointsThe above examples are wrong and don't pass because of the variable name $fullname is wrong.....it's $fullName so the code looks more like
<?php
//Place your code below this comment
$firstName = 'Rasmus'; $lastName = 'Lerdorf';
$fullName = $firstName . ' ' . $lastName;
echo $fullName . " was the original creator of PHP\n";
?>
Andrei Li
34,475 PointsWow, this is finally working. Thank you Rodrigo!
CLOVER STUDIO Ltd. OIB: 01338647868
27,096 PointsWell this is bugging me too, aparently im not displaying correct string. Tried all the solutions here and still : "Bummer! You have not displayed the correct string" I will continue and hope it won't be bugging me in future
<?php
//Place your code below this comment
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullName .= $firstName . ' ' . $lastName;
echo $fullName . " was the original creator of PHP.\n";
?>
Gavin Eyquem
Front End Web Development Techdegree Student 20,732 PointsHere's my code, I'm going wrong somewhere and I've tried many different ways to pass the question.
<?php
//Place your code below this comment $firstName .= "Rasmus"; $lastName .= "Lerdorf"; $fullName = $firstName .''. $lastName;
echo $fullName ." was the original creator of PHP.\n";
?>
Where am I going wrong?
Gavin Eyquem
Front End Web Development Techdegree Student 20,732 PointsI've discovered the problem and have fixed it.
Levi Donaldson
7,692 PointsLevi Donaldson
7,692 Pointschange $fullname to $fullName.