For example, the following code:
Copy the code The code is as follows:
echo 'hellon';
echo 'world';
?>
The newline character n in the program will be output directly and the line break cannot be correct. The solution is to change the single quotes to double quotes:
Copy code The code is as follows:
echo "hellon";
echo "world";
?>
That’s it! In fact, it is the difference between double quotes and single quotes in PHP. In a simple summary, variables in double quotes can be parsed, and single quotes are absolute strings.
Attach: Codes for three methods of removing newlines in PHP
Copy code The code is as follows:
//php Line breaks for different systems
//Different systems The implementation of line breaks is different.
// /n is used in Linux and Unix.
// MAC uses /r.
// In order to reflect the difference between window and Linux, /r/n is used.
//So the implementation methods are different on different platforms
//php has three ways to solve it
//1. Use str_replace to replace newlines
$str = str_replace(array("/ r/n", "/r", "/n"), "", $str);
//2. Use regular replacement
$str = preg_replace('//s*/ ', '', $str);
//3. Use variables defined by PHP (recommended)
$str = str_replace(PHP_EOL, '', $str);
? >
http://www.bkjia.com/PHPjc/748678.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/748678.htmlTechArticleFor example, the following code: Copy the code as follows: ?php echo 'hellon'; echo 'world'; ? Program The newline character n in will be output directly and cannot be correctly wrapped. The solution is to change the single quotes...