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

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

我自己的CMS即将完成,但出于某种原因,文章视图页面在检索时不显示内容中的换行符 数据库。 p>

新行在创建后在“编辑帖子”窗口中显示正常,以便正确保存。 p>

我正在传递内容 通过htmlspecialchars()检索它时会出现什么问题? p>

谢谢, Ilmiont p> div>

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