What is PHP_EOL in PHP?

When you run PHP in a web server, "\n" and "\r\n" will not do anything (it literally just separates the code into different line breaks). <br> makes a new line in HTML (hence "line BReak"). Since you are viewing the PHP in a web browser, it parses the code in HTML. Therefore, "<br>" will make new lines, whereas "\r\n" will not do anything.

cdl_capture_2012-04-06-20_ 000


PHP_EOL is ostensibly used to find the newline character in a cross-platform-compatible way, so it handles DOS/Mac/Unix issues.

Leave a comment