I found a strange bug. I don't know how to solve it. _ PHP Tutorial

Source: Internet
Author: User
I don't know how to solve a strange bug. In textarea, the newline uses rn (ckeditor is also used), but str_replace () cannot be used to process rn. why .? In phptextarea, rn is used for line feed and str_repl is used. In textarea, \ r \ n (ckeditor is also used) is used for line feed, but \ r \ n cannot be processed with str_replace (). I don't know why.

// The newline in textarea uses \ r \ n, and the str_replace method cannot be used !!
// The test1 table only has two fields: id and textarea, and only one record with id = 1.
Require_once 'connect _ text. php ';
Require_once 'show _ message. php ';
If ($ _ POST ['text']) {
$ Text = str_replace ('\ r \ n', '', $ _ POST ['text']);// Try to get rid of it. \ r \ n is not removed from the test result
$ Query = "UPDATE test1 SET textarea = '$ text' WHERE id = '1 '";
$ Result = mysql_query ($ query );
If ($ result ){
Echo "script" alert ('is! ') Script ";
}
}
$ Query = "SELECT textarea FROM test1 WHERE id = '1 '";
$ Result = mysql_query ($ query );
$ Row = mysql_fetch_array ($ result );
?>





Partition (ckeditor is also), but cannot use str_replace () to process \ r \ n. I don't know why. ? In php // textarea, the newline adopts \ r \ n and str_repl...

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.