Print newline with single quotes in PHP
P粉436052364
P粉436052364 2023-08-23 23:53:11
0
2
599
<p>I tried to use single quotes as much as possible, but I noticed that I can't use n inside single quotes. I know I could enter the newline character directly by pressing enter, but that would break the indentation of my code. </p> <p>When I use single quotes, is there some ASCII character or something I can type that will produce a newline? </p>
P粉436052364
P粉436052364

reply all(2)
P粉883278265
echo 'hollow world' . PHP_EOL;

Use the constant PHP_EOL then it is also operating system independent.

P粉543344381

No, because single quotes suppress even hex code replacement.

echo 'Hello, world!' . "\xA";
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!