Home > Backend Development > PHP Tutorial > 字符串处理有关问题preg_replace(),出现奇怪的替换,求大牛解决

字符串处理有关问题preg_replace(),出现奇怪的替换,求大牛解决

WBOY
Release: 2016-06-13 10:17:42
Original
798 people have browsed it

字符串处理问题preg_replace(),出现奇怪的替换,求大牛解决!
http://.com/item.htm?id=14135039282&ref=http%3A%2F%2Fsearch8.taobao.com%2Fsearch%3Fq%3D%25C4%25DA%25BF%25E3%2B%25C4%25D0%26cat%3D50026972%26commend%3Dall%26style%3Dgrid%26ppath%3D2048150%253A105206%26cps%3Dyes%26pid

上面是原字符串,为什么经过下面处理

 

',htmlentities($rw['content'],ENT_QUOTES,GB2312))) ?>



处理后显示成这样,请注意?号后自动换行了,这里想不通
http://.com/item.htm?
id=14135039282&ref=http%3A%2F%2Fsearch8.taobao.com%2Fsearch%3Fq%3D%25C4%2

另外还问个问题,数据库中是这样存储的字符串





而经过',htmlentities($rw['content'],ENT_QUOTES,GB2312))) ?>这样处理后,显示成如下了

 我
 我
 我
 
这里为什么会替换个空格呀,在里层的模式里加了\n就不会出现上面那种情况了

------解决方案--------------------
不用再求解了,这根本就不是问题,就算直接echo出来,?后面也会换行,浏览器把问号之间的字符串当一个单词处理,单词长度超过一屏就回换行,用word编辑英文的时候 一样的效果,所以仅仅是浏览器方面的原因
你可以在下面一段 随便插问号 然后调节浏览器宽度试试

PHP code
<?phpecho "http://.com/item.htm?id=14135039282&ref=http%3A%2F%2Fsearch8.taobao.com%2Fsearch%3Fq%3D%25C4%25DA%25BF%25E3%2B%25C4%25D0%26cat%3D50026972%26commend%3Dall%26style%3Dgrid%26ppath%3D2048150%253A105206%26cps%3Dyes%26pid";<div class="clear">
                 
              
              
        
            
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template