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 Basics Daily Exercise Program String Manipulation

Please tell me what I’m doing wrong?

I’ve been working on this for a minute

index.php
<?php
//Place your code below this comment
$firstName ="Rasmus";
$lastName = "Lerdorf";
$fullName = $firstName + $lastName;
echo "$fullName was the original creator of PHP.\n";
?>

3 Answers

jamesjones21
jamesjones21
9,260 Points

The plus operator in PHP means add and doesn't concatenate, you will need to use the full stop as the concatenate operator. Then as suggested above you'll need to add a space using ' ' an then another full stop after it.

In js the plus sign is used to concatenate :)

Thank You I figured it out! =D

jamesjones21
jamesjones21
9,260 Points

it does cause confusion when going from one language to the next, but in php unless you are not working with numbers then use the full stop :) Plus for maths lol

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

First, have you tried running your code locally or in a workspace or even something like http://phpfiddle.org/.

I'm not sure of the exact expected output from the challenge but the first thing I would double check is your concatenation operator.

ok thanks I will try that

Not sure why the second task is accepted but there is a space between first name and last name

$fullName = $firstName  . ' '. $lastName;