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
Patrick Marshall
1,712 PointsPHP 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
Mike Costa
Courses Plus Student 26,362 PointsHey Patrick,
It looks like you have the semi colon within the string and not at the end of your echo statement.
Patrick Marshall
1,712 PointsI 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?
Mike Costa
Courses Plus Student 26,362 PointsYou 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
Treehouse Guest TeacherMike 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?
Patrick Marshall
1,712 Pointsyes thanks a bunch guys!
Adanna Nwachuku
1,794 PointsI was stuck on the same issue! Thank you everyone! ^_^
Paul Kirsch
2,894 PointsHi thanks, but also, I don't think it was clear in the video that:
- The period comes before the string as well as after it and
- 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.