background image

 

$the_crlf

 = '\n';

//

 

权重大一点

return

 

$the_crlf


 
注意:在前台页面显示的时候,用

nl2br

使换行变成<br>

 
第二种实例说明:
 

 

发现一个有趣的事情:
 

$text

="aaaa 

 
 
ccc"; 
 

$text

=

str_replace

('\n‘,"",

$text

); 

$text

=

str_replace

('\r‘,"",

$text

); 

$text

=

str_replace

('\r\n‘,"",

$text

); 

 

 

正常来说,上面的代码应该可以替换换行符了吧
 

 

但是事实上却是不可以!
 

 

很郁闷,试了很多次,就是不起作用。
 

 

最后改成这样
代码如下:
 

$text

=

str_replace

("\n","",

$text

); 

$text

=

str_replace

("\r","",

$text

); 

$text

=

str_replace

("\r\n","",

$text

); 

 
居然一切 OK 了~~

 

,原来是双引号,单引号的问题!!

 

 

双引号 比单引号效率差点,因为双引号在被 php

 

解析的过程中 ,还会判断里面会不会有

变量,单引号就不会有这个判断,故而一般来讲,没涉及到变量的情况下,我都会用单
引号,没想到这次替换换行符,用单引号居然不行····· 
 

 

最后写成一句话
代码如下:
 

$order

 = 

array

("\r\n", "\n", "\r");