Questions about carriage return when PHP writes to a text file

Source: Internet
Author: User
Questions about Enter when PHP writes to a text file

Today, when writing a log file, it is found that the content written is not wrapped. Some information was found to find some problems.

?

The relevant 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 Write success \r\ntest '); fclose ($FP);

?

The code is not a problem, but after writing the file, \ r \ n will output directly instead of the carriage return.

?

But Windows under \ r \ n really represents a carriage return, and there is no error, depressed for a good while,

?

Later, I changed the quotation marks enclosed in strings from single quotes to double quotes, and everything was OK.

?

Seemingly small differences, but the results are unexpected.

?

Although it is unclear what the reason is, but still 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.