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 trial

hector villasano
12,937 PointsHow to concatenate in PHP
Challenge task 2 of 4 Create a variable called fullName and assign it a value equal to the concatenation of the firstName variable, a space, the middleName variable, a space, and the lastName variable. So i wrote this code and im getting the right output but i still see im getting this wrong?
<?php
$firstName = "Mike";
$middleName = "the";
$lastName = "Frog";
$fullName = $fullname. $firstName . "\n" . $middleName. "\n" . $lastName;
echo $fullName;
echo "The designer at Shirts 4 Mike shirts is named ____";
?>```
and how to do you add code properly? Can some one give me an example.
3 Answers

Jeff Busch
19,287 PointsThis might be easier to read. Take note of the spaces.
<?php
$firstName = "Mike";
$middleName = "the";
$lastName = "Frog";
$fullName = $firstName . " " . $middleName . " " . $lastName;
echo "The designer at Shirts 4 Mike shirts is named " . $fullName . "!";
?>

hector villasano
12,937 PointsThanks a lot! I see i was adding "\n" , that was my problem.

Janelle Smith
5,824 PointsHello Hector, I put spacing in between the periods. I moved the Full Name and concatenate is to your output sentence.
<?php $firstName = "Mike"; $middleName = "the"; $lastName = "Frog"; $fullName = $fullname . $firstName . "\n" . $middleName . "\n" . $lastName; echo $fullName; echo "The designer at Shirts 4 Mike shirts is named " . $fullName; ?>

hector villasano
12,937 Pointsthanks

umut ΓΌnal
431 Pointsthanks
Jeff Busch
19,287 PointsJeff Busch
19,287 PointsHi hector,
If you look to the bottom right of the text box you will see something that says Markdown Cheetsheet. Also, there is a post here titled: Posting Code to the Forum by Dave McFarland. If you don't understand that maybe this will make sense: How to display code at Treehouse.
Jeff