doudou201701 2014-10-17 17:26
浏览 60
已采纳

PHP不会在从数据库中检索的内容中呈现换行符

My own CMS is nearing completion but for some reason the article view page does not show newlines in the content when retrieving from the database.

The newlines display fine in the "edit post" window after creation so they are being saved correctly.

I am passing the content through htmlspecialchars() when it is retrieved so what could be going wrong?

Thanks, Ilmiont

  • 写回答

1条回答 默认 最新

  • douyan6871 2014-10-17 17:27
    关注

    You propably need a $content = nl2br($content) after your htmlspecialchars call to convert the real line breaks to html line breaks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?