Home >Backend Development >PHP Tutorial >Example introduction to the difference between r rn t in php_PHP tutorial

Example introduction to the difference between r rn t in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:39:311143browse

n Soft return:
means a line break in Windows and returns to the beginning of the next line. Equivalent to the effect of r in Mac OS.
In Linux and Unix, it only means line break, but it will not return to the beginning of the next line.

r Soft space:
in Linux and unix means returning to the beginning of the current line.
In Mac OS, it means wrapping and returning to the beginning of the next line, which is equivalent to the effect of n in Windows.

t Tab (move to next column).

They are valid in strings represented by double quotes or delimiters, but not in strings represented by single quotes.
rn is generally used together to represent the Enter key on the keyboard, or just n can be used.
t represents the "TAB" key on the keyboard.

Just like the difference between using enter and shift+enter, if you want to display the effect on the page, you need to convert it into HTML code or use...

Newline symbol in the file:

linux, unix: rn
windows: n
Mac OS: r

corresponds to:

n LF or 0x0A(10) in ASCII
r 0x0D(13) in CR or ASCII
t Horizontal tab - 0x09 (9) in HT or ASCII
\ backslash
$ dollar sign
" double quote
' Single quotation marks

about their origins and cause differences:

The origins and differences between the two concepts of "carriage return" and "line feed" .
Before the advent of computers, there was a thing called the Teletype Model 33, which could type 10 characters per second. But it had a problem, which was that it had to use a new line after typing. If you go to 0.2 seconds, you can type two characters. If a new character is transmitted during this 0.2 seconds, the character will be lost

So, the developers thought of a way to solve this problem. Just add two characters to indicate the end of each line. One is called "carriage return", which tells the typewriter to position the print head at the left border; the other is called "line feed", which tells the typewriter to move the paper down one line. 🎜>This is the origin of "line feed" and "carriage return", which can be seen from their English names

Later, the computer was invented, and these two concepts were introduced to computers. At that time, memory was very expensive, and some scientists thought it was too wasteful to add two characters at the end of each line. So, there was a disagreement. In Unix systems, only one character was added at the end of each line. "", which is "n"; in Windows system, the end of each line is "", which is "nr"; in Mac system, the end of each line is "< "Enter>". A direct consequence is that if a file under Unix/Mac system is opened in Windows, all text will become one line; while if a file in Windows is opened under Unix/Mac, at the end of each line There may be an extra ^M symbol.

When programming in C language (windows system)

r is return. Returning to the beginning of this line will overwrite the previous output of this line

For example:



Copy code

The code is as follows: int main() { cout < < "hahaha" << "r" << "xixi" ;
}


Finally only xixi is displayed and hahaha back covers

n Yes Enter + line feed. Move the cursor to the beginning of the line first and then change to the next line, which is the beginning of the next line. Pull



Copy the code
The code is as follows: int main() {
cout << "hahaha" << "n" << "xixi" ;
}


will display:

hahaha
xixi



http://www.bkjia.com/PHPjc/730058.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/730058.htmlTechArticlen Soft return: In Windows, it means a line break and returns to the beginning of the next line. Equivalent to the effect of r in Mac OS. In Linux and Unix, it only means line break, but it will not return to the next line...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn