PHP newline not working in text file

后端 未结 7 426
无人共我
无人共我 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:13

    '\n' in single quotes is a literal \n.
    "\n" in double quotes is interpreted as a line break.

    http://php.net/manual/en/language.types.string.php

提交回复
热议问题