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 trialAaron Boyse
Courses Plus Student 1,924 PointsConcatenation in PHP
I am stuck on this code in my Beginner PHP course. I want to print out to the screen the first name, last name, "was the original creator of PHP" and use an escape character.
Can anyone show me where my code is wrong?
[code]
<?php
//Place your code below this comment $firstName = "Rasmus"; $lastName = "Lerdorf";
$fullName = $firstName." ".$lastName;
$fullName = $firstName . "\n" . $lastName ."\n". 'was the original creator of PHP.'; ?>
[/code]
1 Answer
philippulbrich
11,975 PointsHi Aaron,
That's almost true. Issue the command "echo" and use the newline character only at the end! Use doubleqoutes for the text to interpret the newline character. I've included the solution below.
I hope I could help you out.
<?php
$firstName = "Rasmus";
$lastName = "Lerdorf";
$fullName = $firstName . " " . $lastName;
echo $fullName . " was the original creator of PHP. \n";
?>
Aaron Boyse
Courses Plus Student 1,924 PointsAaron Boyse
Courses Plus Student 1,924 PointsIt does Philipp, I was saying echo $fullName = $firstName." ".$lastName." ". was the original creator of PHP.";
Glad you cleared that up for me.
Thank you