user2634873
user2634873

Reputation: 49

Display HTML without stripping tags or converting to html entities

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.

Upvotes: 0

Views: 1692

Answers (1)

Canis
Canis

Reputation: 4410

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);

Upvotes: 1

Related Questions