[ACCEPTED]-How to resolve PHP PHP_EOL issue-php

Accepted answer
Score: 13

Some "fixes":

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

  2. Don't use notepad.

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

Score: 8

Don't use PHP_EOL for text-file output.

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

You 1 can DEFINE or $var it if you want.

Score: 1

Use the nl2br() function:

echo nl2br("your first line\n your second line"); 

0

Score: 0

You can read text log file to html with 1 line break. This works in Windows and Linux/Unix:

echo str_replace("\n", '<br>', file_get_contents($logfilename));

More Related questions