The question about the carriage return when php writes a text file is found today when writing a log file, the written content does not wrap. I checked some information to find some problems .? The related code is as follows :? File_put_contents ($ _ SESSION [projectname], the balance sheet is successfully written into rn, FILE_APPEND );? Or? Why fpfopen(log.txt about carriage return when php writes a text file
When writing a log file today, it is found that the written content will not wrap. I checked some information to find some problems.
?
The related code is as follows:
?
File_put_contents ($ _ SESSION ['projectname'], 'balance sheet written successfully \ r \ n', FILE_APPEND );
?
Or
?
$ Fp = fopen('log.txt ', 'A'); fwrite ($ fp, 'balance sheet written successfully \ r \ ntest'); fclose ($ fp );
?
The code is correct, but \ r \ n will be output directly after the file is written, rather than press Enter.
?
However, in windows, \ r \ n does mean a carriage return, and there is no error. after a while,
?
Later, I changed the string-enclosed quotation marks from single quotation marks to double quotation marks, and everything was OK.
?
Seemingly small differences, but the results are indeed unexpected.
?
Although I don't know why, keep a record
?