"AJAX Basics (retiring)" was retired on February 5, 2020. You are now viewing the recommended replacement.

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

PHP

How 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.

Hi 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

3 Answers

This 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 . "!";

?>

Thanks a lot! I see i was adding "\n" , that was my problem.

Hello 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; ?>

thanks

thanks