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

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.