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

PHP concatenate Contact Form Code Challenge

It says I need to add an exclamation but I did, and I tried every which way but nothing seems to work. Is there a quick fix to this problem?

<?php

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

$fullName= $firstName . " " . $middleName . " " . $lastName;



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

?>

7 Answers

Hey Patrick,

It looks like you have the semi colon within the string and not at the end of your echo statement.

I then try this echo "The designer at Shirts 4 Mike shirts is named $fullName !"; and it still doesnt work. I then try and leave a space for the exclamation point and it still doesnt work. How do I concatenate within the string?

You can try 1 of 2 ways to do this. One is to concatenate the exclamation point to the string like this:

echo "The designer at Shirts 4 Mike shirts is named " . $fullName . "!";

Or you can use interpolation on the variable within the string like this:

echo "The designer at Shirts 4 Mike shirts is named {$fullName}!";

Hope that helps!

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

Mike is right; the way we've covered how to do it in the videos is that first way:

echo "The designer at Shirts 4 Mike shirts is named " . $fullName . "!";

Does that work for you?

yes thanks a bunch guys!

I was stuck on the same issue! Thank you everyone! ^_^

Hi thanks, but also, I don't think it was clear in the video that:

  1. The period comes before the string as well as after it and
  2. That an additional quote sign is needed before the period and string. I think this should be a guidance response in the "bummer" rejection. Otherwise high stress for noobs. This is also in keeping with the excellent ease-of-learning and encouragement that Treehouse provides.