Line feed of txt notepad file generated by php

Source: Internet
Author: User
Tags chr

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:
<? Php
$ 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

Related Article

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.