dongyuelian9602 2017-08-10 11:30
浏览 185
已采纳

显示HTML而不剥离标记或转换为html实体

I want to display HTML as it is created in summernote editor in a page. But when I use echo it displays HTML as "<div><h1>" etc. It did not display the contents as in the editor.

I want is there any function to display HTML as it is created inside a WYSIWYG editor in PHP.

This is the code I have

<div class="post_content">
    <div class="post_meta">
        <h2>
            <?php echo ucfirst($questionpaper[0]['title']); ?>
        </h2>
    </div>

    <?php
    $description = $questionpaper[0]['description'];
    echo $description;
    ?>
</div>

I want to display the description as it is created inside summernote editor. But currently I am getting output with HTML tags as plain text.

Currently the output I am getting looks like this:

<div>Lorem ipsum.</div><div><br></div><div>Lorem ipsum</div>

But I want the HTML tags parsed. Is there any function or library in PHP for doing this.

  • 写回答

1条回答 默认 最新

  • duanbinmi8970 2017-08-10 11:36
    关注

    You are converting the tags to plain text using htmlentities() here:

    echo htmlentities($description);
    

    Change it to just:

    echo $description;
    

    EDIT

    You just updated your question removing the htmlentities() I was referring to, but if you are still getting plain text you can try to do this:

    echo html_entity_decode($description);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题