When do I use the PHP constant “PHP_EOL”?

前端 未结 19 2577
攒了一身酷
攒了一身酷 2020-11-22 06:21

When is it a good idea to use PHP_EOL?

I sometimes see this in code samples of PHP. Does this handle DOS/Mac/Unix endline issues?

19条回答
  •  独厮守ぢ
    2020-11-22 07:01

    I'd like to throw in an answer that addresses "When not to use it" as it hasn't been covered yet and can imagine it being used blindly and no one noticing the there is a problem till later down the line. Some of this contradicts some of the existing answers somewhat.

    If outputting to a webpage in HTML, particularly text in