Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics Daily Exercise Program String Manipulation

kingdavid igbayilola
kingdavid igbayilola
8,678 Points

php

i am getting an error in this

$fullName = $firstName + $lastName 'was the original creator of PHP'"\n";

can't find the problem there

index.php
<?php

//Place your code below this comment
$firstName = 'Rasmus';
$lastName = 'Lerdorf';

$fullName = $firstName + $lastName 'was the original creator of PHP'"\n";






?>

4 Answers

it's because of the "\n" part you are including at the end. In order for that to be added on you would need to do the following:

$fullName = $firstName . $lastName .'was the original creator of PHP' . "\n";

Then after all of that you should end up with something that looks along the lines of:

<?php
$firstName = 'Rasmus';
$lastName = 'Lerdorf';

$fullName = $firstName . $lastName .'was the original creator of PHP' . "\n";

echo $fullName;
?>

Hello Kingdavid,

If you're trying to print the following variable but are getting errors then I here is the solution to do just that.

<?php
$firstName = 'Rasmus';
$lastName = 'Lerdorf';

$fullName = $firstName . $lastName .'was the original creator of PHP';

echo $fullName;
?>

Sorry if this is not exactly what you're after, but that is how you would echo the values correctly without getting errors when combining other variables and strings into one variable.

kingdavid igbayilola
kingdavid igbayilola
8,678 Points

I am still getting this error message

Bummer: syntax error, unexpected '" \n"' (T_CONSTANT_ENCAPSED_STRING) in index.php on line 7

<?php

//Place your code below this comment $firstName = 'Rasmus'; $lastName = 'Lerdorf';

$fullName = $firstName. $lastName.'was the original create of PHP'" \n";

echo $fullName; ?>

Hi David,

Regarding your latest comment, you'd need to do:

$fullName = $firstName. $lastName.'was the original create of PHP' . " \n";

Note the . between the string and the \n.