Matt Matt - 2 years ago 150
PHP Question

Print newline in PHP in single quotes

I try to use single quotes as much as possible and I've noticed that I can't use \n in single quotes. I know I can just enter a newline literally by pressing return, but that screws up the indentation of my code.

Is there some ASCII character or something that I can type that will produce newline when I'm using single quotes?

Answer Source

No, because single-quotes even inhibit hex code replacement.

echo 'Hello, world!' . "\xA";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download