PHP newline Php_eol

Source: Internet
Author: User
In the Unix world to line up with/n instead, but windows in order to reflect his differences, the use of/r/n, more interesting is the Mac with/R. So the UNIX series with the/n,windows series with the/r/n,mac with/R, so that you write the program on different platforms run with a lot of trouble. Here are some common ways to remove line breaks from PHP.

The first type of notation:
$content =str_replace ("\ n", "", $content);
Echo $content;

The second way:
Str_replace ("\ r \ n", "", $str);

The third type of notation:
$content =preg_replace ("/\s/", "", $content);
Echo $content;

Php_eol is a well-defined variable that represents the PHP newline character, which changes depending on the platform, is/r/n under Windows,/n under Linux, and/R under Mac. Line-up will be as follows.
$str = Str_replace (Php_eol, ", $STR);

PHP newline Php_eol

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.