On the problem of php newline characters

I print newline characters under mac

var_dump(PHP_EOL);

Google displays the source code as follows:
clipboard.png

html:

clipboard.png

then the print result shows that PHP_EOL on mac is equivalent to\ n

.

and Baidu"s results are as follows:
\ n: UNIX system line Terminator
\ n\ r: window system Line Terminator
\ r: MAC OS system Line Terminator

so, does anyone know why? A very strange question

Apr.13,2022

try to go to Wikipedia when you have questions, don't go to Baidu, post it, you know, library.

the MAC OS here is the very old operating system used in the old Apple desktop system, which has been disabled since 2002.

All operating systems after

are Unix core, so drink Unix just like that.


different operating system newline characters are different, so PHP_EOL is defined as automatic adaptation, which represents different values under different operating systems, which can improve the portability of the source code. A similar usage is DIRECTORY_SEPARATOR .

Menu