Home  >  Article  >  Backend Development  >  用PHP EOL来替换/r/n进行换行

用PHP EOL来替换/r/n进行换行

WBOY
WBOYOriginal
2016-06-20 13:02:381074browse

写程序时会经常用到换行,用PHP内置常量PHP_EOL来进行换行。

一个小小的换行,在不同的平台有着不同的实现。在unix世界换行就用\n来代替,但是windows为了体现他的不同,就用\r\n,更有意思的是在mac中用\r。

因此unix系列用 \n,windows系列用 \r\n,mac用 \r。

因此系统会根据平台系统的不同,转换成不同的换行。

如果要在浏览器中换行,就要使用PHP_EOL变量进行换行。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn