Making a new line with single quotes?

倾然丶 夕夏残阳落幕 提交于 2019-11-28 09:06:51

问题


Can I do a line break like this '\n'?

Or do I must use double quotes - "\n"?


回答1:


You have to use double quotes. Otherwise, PHP will literally output \n.

http://php.net/manual/en/language.types.string.php




回答2:


To output a newline (or any other control character for that matter) you must always use double quotes.

An alternative to not use double quotes is chr() with the respective ASCII code as an argument:

echo chr(10); // same as echo "\n";



回答3:


just add

.PHP_EOL;

to the end of your line using single quotes and you will have a new line




回答4:


No - \n in single quotes is '\n'.
Yes - you have to use double quotes.



来源:https://stackoverflow.com/questions/7890217/making-a-new-line-with-single-quotes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!