PHP newline not working in text file

后端 未结 7 421
无人共我
无人共我 2021-02-02 08:41

I am using the PHP code:

$numberNewline = $number . \'\\n\';
fwrite($file, $numberNewline);

to write $number to a file.

For some reason

7条回答
  •  情歌与酒
    2021-02-02 09:07

    Use PHP_EOL. PHP_EOL is platform-independent and good approach.

    $numberNewline = $number .PHP_EOL;
    fwrite($file, $numberNewline);
    

    PHP_EOL is cross-platform-compatible(DOS/Mac/Unix).

提交回复
热议问题