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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?