php - 使用 CkEditor 显示保存在数据库中的文本(HTML)

标签 php mysql ckeditor richtext

我用过 CKEDITOR 用于在 中保存一些文本mysql 数据库 ,它以如下所示的格式保存

<p style="margin: 0px; padding: 0px; border: 0px; color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">
    <span style="font-size: 14px;"><span style="font-family: arial, helvetica, sans-serif;">Buy 2 Buffet and Get 1 Free (Mon-Wed-Thu-Fri-Sat-Sun)</span></span><br />
    <span style="font-size: 14px;"><span style="font-family: arial, helvetica, sans-serif;">Lunch buffet-</span></span><span style="font-size: 14px;"><span style="font-family: arial, helvetica, sans-serif;"><strong>Rs.399</strong><br />
    Dinner Buffet-</span></span><strong><span style="font-family: arial, helvetica, sans-serif; font-size: 14px;">Rs.499</span></strong></p>
<p style="margin: 0px; padding: 0px; border: 0px; color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">

为了显示它,我使用了 php 代码,例如
echo htmlspecialchars_decode(stripslashes($main_row['meta_value']))

但它显示的输出如下
<p style="margin: 0px; padding: 0px; border: 0px; color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">  
<span style="font-size: 14px;"><span style="font-family: arial, helvetica, sans-serif;">Buy 2 Buffet and Get 1 Free (Mon-Wed-Thu-Fri-Sat-Sun)</span></span><br /> <span style="font-size: 14px;"><span style="font-family: arial, helvetica, sans-serif;">Lunch buffet-</span></span><span style="font-size: 14px;"><span style="font-family: arial, helvetica, sans-serif;"><strong>Rs.399</strong><br /> Dinner Buffet-</span></span>

我想将此数据显示为文本,请帮帮我。

最佳答案

尝试使用

echo htmlspecialchars_decode($text);

它会起作用。

关于php - 使用 CkEditor 显示保存在数据库中的文本(HTML),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20844984/

相关文章:

php - 根据 WooCommerce 中的自定义字段值将文本添加到订单摘要

php - 使用 php 创建和获取动态变量

php - 为什么 PHP strtolower 的性能变化如此之大?

mysql - SQL Server 是否有等同于 MySql 的 sql_no_cache 修饰符?

javascript - 如何在ckeditor中定义列

javascript - 更新后添加youtube-video后的CKEditor Rails空白页

php - 从 PHP 执行 wkhtmltopdf

mysql - 如何从一条记录的两个字段中获取最大值

mysql - Navicat 精要 (11);无法连接到mysql服务器

javascript - 根据顶部和底部的高度改变内容高度