[Switch] use PHP to remove line breaks and PHP_EOL variables about n, r, t? N soft press enter :? In Windows, it indicates a line break and returns to the start position of the next line. in Linux and unix, it only indicates a line break, but does not return to the start position of the next line .? R soft space :? In Linux and unix, it indicates to return to the first position of the row .? In MacOS, the line feed is displayed and returned to the start position of the next line. this is equivalent to converting PHP to remove the use of line breaks and PHP_EOL variables.
About \ n, \ r, \ t?
\ N soft carriage return :? In Windows, it indicates a line break and returns to the start position of the next line. in Linux and unix, it only indicates a line break, but does not return to the start position of the next line .?
\ R soft space :? In Linux and unix, it indicates to return to the first position of the row .? In Mac OS, it indicates a line break and returns it to the start position of the next line, which is equivalent to \ n in Windows .?
\ T hop (move to the next column )?
What are the notes :?
- They are valid in double quotes or delimiters. they are invalid in single quotes .?
- \ R \ n is generally used together to represent the carriage return key (in Linux and Unix) on the keyboard. \ n (in Windwos) can also be used only, and \ r is used to represent the carriage return in Mac OS.
- \ T indicates the "TAB" key on the keyboard .?
- File line break: windows: \ n, linux, unix: \ r \ n
// Different php systems use different line breaks. // different systems use different lines. // for linux and unix, use/n // for MAC, and use/r // window to reflect differences from linux. it is/r/n // so the implementation methods are different on different platforms // php has three methods to solve the problem // 1. use str_replace to replace the line feed $ str = str_replace (array ("/r/n ", "/r", "/n"), "", $ str); // 2. use regular expressions to replace $ str = preg_replace ('// s */', '', $ str); // 3. use the variables defined in php (recommended) $ str = str_replace (PHP_EOL,'', $ str );
?
????? PHP_EOL (end of line) is a defined variable that represents the line break of php. this variable will change according to the platform. in windows, it will be/r/n, in linux, it is/n, and in mac, it is/r. line Feed is followed by the following line.
?
$str = str_replace(PHP_EOL, '', $str);
?
?
This article