Invalid newline character in the PHP string, workaround for wrapping line

Source: Internet
Author: User

  This article mainly describes the PHP string in the invalid line break, can not wrap the solution, in fact, PHP is the double quotes and single quotes use problems, the need for friends can refer to the following

For example, the following code:     Code is as follows: <?php echo ' Hellon '; echo ' World ';?> the newline character N in the program is directly output, the line cannot be wrapped correctly, the solution is to change the single quotation mark to double quotation mark:   Code is as follows: <?php echo "Hellon"; echo "World";?> that's it! In fact, PHP's double quotes and single quotes, the difference between the simple generalization of double quotes in the variable can be resolved, single quotes is an absolute string.  : PHP To remove the line of three methods code     code as follows: <?php         //php different system of the new line      //No The implementation of line wrapping between the systems is different      //linux with UNIX/n      //MAC with/R      //window to reflect Unlike Linux, it's/r/n      /So it's not the same on different platforms      //php has three ways to resolve         1. Use Str_replace to replace line       $STR = str_replace (Array ("/r/n", "/R", "N"), "", $str);         //2, using regular replacements       $STR = preg_replace ('//s*/', ', ', $str);        //3, using PHP defined variables (recommended)       $STR = Str_replace (Php_eol, ', $str);   ?>    

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.