Home > php教程 > php手册 > 发现一个诡异的bug,不知何解

发现一个诡异的bug,不知何解

WBOY
Release: 2016-06-13 11:30:49
Original
1136 people have browsed it

textarea中换行使用\r\n(ckeditor也是),可是却不能用str_replace()将\r\n进行处理,不知道为什么。

// textarea中换行采用\r\n,并且用str_replace方法不能搞掉!!
//test1表只有id、textarea两个字段,且只有id=1的一条记录。
require_once 'connect_text.php';
require_once 'show_message.php';
if($_POST['text']){
    $text = str_replace('\r\n', '', $_POST['text']);          //尝试搞掉,测试结果没有去掉\r\n
    $query="UPDATE test1 SET textarea = '$text' WHERE id = '1'";
    $result = mysql_query($query);
    if($result){
        echo "<script>alert('成了!')</script>";
    }
}
$query = "SELECT textarea FROM test1 WHERE id = '1'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
?>



//尝试搞掉,测试结果没有去掉\r\n
    


    



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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template