Questions about carriage return when php writes a text file

Source: Internet
Author: User
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

?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.