keep textarea input format after using mysql_real_escape_string to store

前端 未结 5 999
时光说笑
时光说笑 2021-01-14 05:05

I am using php5.3.6 and mysql 5.1.56 and CodeIgniter. Here is what I did.

  1. Input some text in textarea, something like this:


    what\'s this?

5条回答
  •  逝去的感伤
    2021-01-14 05:49

    The Best Solution..

    $insertdata = mysql_real_escape_string($string); (You can insert it in your database if you want)

    echo stripslashes(str_replace('\r\n',PHP_EOL,$insertdata)); (The output is exactly as your input was)

提交回复
热议问题