文本显示带有标签

Text appears with tags

那么这段代码有什么问题呢? $content 包含带有 html 标签的文本,但是,当我 post 某些东西时,标签不起作用并显示为纯文本。

    <?php
        require_once("nbbc/nbbc.php");
        $bbcode = new BBCode;
        $sql = "SELECT * FROM posts ORDER BY id DESC";
        $res = mysqli_query($db, $sql) or die(mysqli_connect_error());
        $posts = "";
        if (mysqli_num_rows($res) > 0){
            while($row = mysqli_fetch_assoc($res)) {
                $id = $row['id'];
                $title = $row['title'];
                $content = $row['content'];
                $date = $row['date'];

                $output = $bbcode->Parse($content);
                    if (strlen($output) > 1000) {
                        $stringCut = substr($output, 0, 1000);
                        $output = substr($stringCut, 0, strrpos($stringCut, ' '))." ... <a href='view_post.php?pid=$id'>Lasīt Vairāk</a>"; 
                    }
                $posts .="<div><h1 style='margin-left:0'><a href='view_post.php?pid=$id'>$title</a></h1><p style='margin:3px; font-style:italic; opacity: 0.6;'>$date<p><p>$output</p></div><hr>";
            }
            echo $posts;
        } else {
            echo "Oops, no new posts";
        }

    ?>

如果 $content 以编码形式存储,即标签被翻译成 &lt;&gt; 然后使用 PHP 本机函数 html_entity_decode($content) 对其进行解码到真正的 <> 个字符。

html_entity_decode — Convert all HTML entities to their applicable characters