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

Could you please help me with this code challenge?

Hi Leon,

Could you please post what you have tried so far?

<?php

$firstName = "Mike";
$middleName = "the";
$lastName = "Frog";

$fullName = $fullName . $firstName;

$fullName = $fullName . $middleName;

$fullName = $fullName . $lastName;

echo "The designer at Shirts 4 Mike shirts is named ____";

?>

Nearly there Leon,

What you've wrote echos this:

MikeTheFrog

Remember that you need a space in between the words.

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Leon;

To concatenate strings with spaces in between in PHP you would use the following syntax:

$foo = "foo";
$bar = "bar";
$baz = $foo . " " . $bar;

Now if you do an echo $baz; statement you will get "foo bar". If you don't include that concatenated space you would get "foobar".

Happy coding,

Ken

<?php
$firstName = "Mike";
$middleName = "the";
$lastName = "Frog";
$fullName = $firstName.' '.$middleName.' '.$lastName;

echo "The designer at Shirts 4 Mike shirts is named $fullName";
?>