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

Duncan Gilmour
Duncan Gilmour
1,563 Points

How is my code not correct?

I am getting a Bummer response to my code input on this String manipulation test. I don't see what is wrong - and it comes out OK in the preview and in a browser.

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";
?>
Konrad Pilch
Konrad Pilch
2,435 Points

What's the question?

2 Answers

Filipe Pacheco
seal-mask
.a{fill-rule:evenodd;}techdegree
Filipe Pacheco
Full Stack JavaScript Techdegree Student 21,416 Points

Your code is right, just take off the space between PHP and \n. Instead of PHP \n, do PHP\n and it will work.

By the way, although it works, you don't need the quotation marks around the variables, if you are concatenating them. You can do:

$fullname = "$firstName $lastName";

or 

$fullname = $firstName . " "  . $lastName;
Duncan Gilmour
Duncan Gilmour
1,563 Points

The question is in the title:

How is this code not correct? I can't get past the code checker yet it looks ok to me in the preview window and in independent browsers. Maybe it is not as elegant as you would like but it seems to work.

Konrad Pilch
Konrad Pilch
2,435 Points

Try this line maybe.

$fullname = "$firstName" . "$lastName";

I mean what is the challenge question, not your obviously. I don't know what can be wrong with this if i don't know what they are asking for. But try the line above instead of the line you got.