Php generates txt notepad file line breaks-PHP source code

Source: Internet
Author: User
When a 404 error bad_url error is automatically generated when a deleted file is created, the generated txt file does not have line breaks. After being submitted to Baidu, the system prompts a format error, I will share with you the solution to this problem step by step. When a 404 error bad_url error is automatically generated when a deleted file is created, the generated txt file does not have line breaks. After being submitted to Baidu, the system prompts a format error, I will share with you the solution to this problem step by step.

Script ec (2); script

1. Analysis of incorrect practices

// Add the error page below and submit it to Baidu

The Code is as follows:
$ Hand = fopen ("$ path/bad_url.txt", "");
Fwrite ($ hand, "\ r". 'HTTP: // www.111cn.net '. $ rs ['your address']);
Fclose ($ hand );

The result shows that the output is

Http://www.111cn.net/database/mysql/57520.htm http://www.111cn.net/wy/js-ajax/57519.htm
This kind of continuity is not what I want

Http://www.111cn.net/database/mysql/57520.htm
Http://www.111cn.net/wy/js-ajax/57519.htm

I did not think about using chr (13) or chr (32) Like ascii code. I have handled the carriage return and line feed of the htm form, after the test, it still does not work. At that time, it is only a hundred degrees.

The Code is as follows:
$ Stream = fopen ("robots.txt", "w + ");
Fwrite ($ stream, "are you breaking the line? \ R \ n I already have a line break! ");
?>

Note: Do not use single quotes in the code. I am wrong in this step. If single quotes are used, the output will be User-agent: * \ r \ nDisallow: /Because the single quotes in PHP do not replace the content, double quotation marks are used, because the double quotation marks in PHP are used to check the content.

After several times, you can delete the file, which is the expected result.

To sum up, this \ r \ n small editor has tried \ n \ r and seems to be useless. It's just basic knowledge or you don't have to forget it for a long time.

Site Original: Reprinted indicated source http://www.111cn.net

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.