工学1号馆

home

文本写入数据库与读出显示

Wu Yudong    February 27, 2019     ThinkPHP   519   

在实现文章的添加与读取的时候,需要将其写入数据库与读出操作

这里使用的是baidu的Ueditor富文本框编辑,

<textarea name="content" rows="100%" style="width:100%" id="myEditor"></textarea>
<script type="text/javascript">
	var editor = new UE.ui.Editor({initialFrameHeight:250});
	editor.render("myEditor");
</script>

后台使用tp5实现,要获取content中的内容,

$content = htmlspecialchars_decode(input('content'));

接着存入数据库,在数据库中存储的是带格式的文本,也即是带html标签

如果需要读出显示在页面,代码如下:

{$article.content|raw}

 

如果文章对您有帮助,欢迎点击下方按钮打赏作者

Comments

No comments yet.
To verify that you are human, please fill in "七"(required)