Take the 2-minute tour ×

the constant:



Any quick fix to the issue?



share|improve this question

2 Answers 2

up vote 3 down vote accepted

Some "fixes":

  1. Use \r\n for your line breaks to make Windows happy.

  2. Don't use notepad.

PHP_EOL only represents something per the system it's running on. It cannot possibly simultaneously represent every EOL sequence that each OS uses.

share|improve this answer
konforce - no need for the \r\n on windows as the above works fine (find and replace is of course possible here but based on my knowledge, this should work regardless) –  JM4 Apr 1 '11 at 2:07
If you create a file on Windows using PHP_EOL it will look fine in Notepad. If you create that same file on Linux using PHP_EOL it will not work on Notepad. In what case are you having a problem? –  Matthew Apr 1 '11 at 2:10
@konforce - thanks for the suggestion on Notepad, viewing in word or even WordPad generates desired results. Any chance the line break (not showing in notepad) would actually be an issue? –  JM4 Apr 1 '11 at 2:10
of note: even when echoing to a screen output (html) shouldn't the PHP_EOL create a break in the text on the screen? –  JM4 Apr 1 '11 at 2:12
@JM4, Notepad only knows about "\r\n". So really the only solution is to not use Notepad or to use what it wants. Linux programs are typically smarter and will know how to parse "\r\n" even though they really just want "\n". The best solution depends on who these files are for, etc. PHP_EOL will not create a break in HTML (only the BR or similar tag will) and if you "view source" you will have the same problem if Notepad is the editor of choice. –  Matthew Apr 1 '11 at 2:12

Don't use PHP_EOL for text-file output.

IIRC it's better to use "\r\n" for best compatibility.

You can DEFINE or $var it if you want.

share|improve this answer
good suggestion - went with konforce for noting that it does in fact work, just not using notepad. –  JM4 Apr 1 '11 at 2:27

Your Answer


