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

Error with string :(

<?php

//i Tried everything but nothing work ! $firstName = "Rasmus " ; $lastName = " Lerdorf" ; $fullname = "$firstName" . " " . "$lastName " ; echo $fullname ; ?>

index.php
<?php

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

1 Answer

Tanja Schmidt
Tanja Schmidt
11,798 Points

I guess you're at the second task of the challenge? If so: Delete the last line of your code plus the extra spaces inside the quotes in the lines above and your code should work. That is because you're asked to create a third string in this task but not to print it to the screen yet.

<?php

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

?>

You could also write it this way:

<?php

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

Makes it a bit easier to read imho. Happy Coding! :)