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

So I'm on a challenge question and I'm confused.

Question:

Create a third variable named fullName that combines the $firstName and $lastName variables to make the string Rasmus Lerdorf.

My code:

<?php

//Place your code below this comment $firstName="Rasmus"; $lastName = "Lerdorf"; ?>

Thanks!

2 Answers

Steven Parker
Steven Parker
229,732 Points

The code you begin with (shown here) defines "$firstName" and "$lastName" variables.

For this challenge, you'll create another variable named "$fullName", and use the other two variables to store a value in it. Using the concatenation operator ("."), you can join the other names plus put a space between them.

For some reason, it's still not letting me do it, though.

Here is the code I put:

<?php

//Place your code below this comment $firstName = "Rasmus"; $lastName = "Lerdorf"; $fullName = $firstName . $lastName; ?>

I thought this concatenated $firstName & $lastName, and combined the two variables with a space, but for some reason, the test isn't accepting the answer.

Steven Parker
Steven Parker
229,732 Points

The concatenation operator doesn't add anything. But you can place a literal space (in quotes) between the names and combine it with an additional operator.

And when posting code, preserve the appearance by using Markdown formatting.