0

Obviously it's not "\r\n",which only fits windows,and will cause ^M on linux

omg
  • 136,412
  • 142
  • 288
  • 348
  • Actually, CRLF is more common than you think. HTML/XML specs allow CRLF and the HTTP spec actually enforces the use of CRLF as EOL for headers. – Christian Jun 16 '12 at 19:36

2 Answers2

12

PHP_EOL

Community
  • 1
  • 1
Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539
2

a new line in php is just "\n". should work on all platforms.

AvatarOfChronos
  • 867
  • 9
  • 24
  • Don't we all use "\r\n" on windows? – omg Jun 13 '09 at 01:16
  • 2
    Using "\n" has always worked for me as a newline in php. and I've worked in both Linux and Windows environments. – AvatarOfChronos Jun 13 '09 at 02:18
  • The new line \n should work across all systems as long as the data is being used by php, the problems with \n vs \r\n come up when the data is created by php but used by another application, for instance, you write a document on linux using the \n within php, this file is then opened in a windows document software and you might see "unexpected" abnormalities in the way the data displays. I quoted unexpected because we can expect them but somebody not knowing this might be surprised by the output. – CodingInTheUK Aug 14 '19 at 09:26