PHP newline not working in text file

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

    None of the above worked for me but it was so simple - here is the code... please use the KISS method.

    echo file_put_contents("test.txt","\r\n \r\n$name \r\n$email \r\n$phone", FILE_APPEND);
    

    It set a new blank line and then appends one line at a time.

提交回复
热议问题