Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

file_put_contents and a new line help

Tags:

php

I've got a file that I'm writing to and I cannot get file_put_contents to append the next entry on a new line, even after a newline character. What am I missing? I'm on a windows machine.

$file = 'test.txt'; $message = "test\n\n"; file_put_contents($file, $message, FILE_APPEND); 
like image 781
jim Avatar asked Feb 24 '10 10:02

jim


1 Answers

try

$file = 'test.txt'; $message = "test".PHP_EOL; file_put_contents($file, $message, FILE_APPEND); 

or

$file = 'test.txt'; $message = "test\r\n"; file_put_contents($file, $message, FILE_APPEND); 
like image 99
Mathieu Avatar answered Sep 23 '22 02:09

Mathieu