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 Escape Sequence

Darya Zata
Darya Zata
2,562 Points

why is \n is written before closing q.marks "

the line $string_one= "Learning to display \"Hello $name!\" to the screen\n" ; is correct but i would rather write it (like f.e. in java) $string_one= "Learning to display \"Hello $name!\" to the screen"\n ; which throws error why would it throw an error?

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Darya

Each Language will have its own syntax. Sometimes there are similarities across them, but also many differences. In PHP, the newline character needs to be part of the string, and thus, inside the quotation marks. Outside will be a syntax error.
You'll see as you come into contact with other languages, that many things that work in one will throw errors in another.
Keep Coding! :) :dizzy: