如何在sql数据库中保存键盘中的“Enter”[复制]

This question already has an answer here:

Can someone tell me how can I save keyboard ENTER as <br> in database? I have textarea for status update but whenever I press ENTER key it do nothing... And same as that how can I save code as text not as code?

</div>

You could use nl2br. This will put BR's in automatically as long as your database does not already contain 's. If it does this function won't convert them. However textarea's don't add those by default so you should be fine. The following page has the description of the function:

http://php.net/manual/en/function.nl2br.php