Question

I have an HTML WYSIWYG that is added into the db using

'page_description' => htmlspecialchars($this->input->post('content'));

When I view on the frontend I get enter image description here

How can I decode it so it shows as HTML?

Was it helpful?

Solution

The function that is intended in PHP to be a sort of inverse to htmlspecialchars/htmlentities is html_entity_decode.

OTHER TIPS

Remove the htmlspecialchars bit. That's converting < into &lt; so it prints out as the actual symbol, ignored by the browser as the start of an HTML tag.

'page_description' => $this->input->post('content');

From: http://us2.php.net/htmlspecialchars

The translations performed are:

'&' (ampersand) becomes '&amp;'
'"' (double quote) becomes '&quot;' when ENT_NOQUOTES is not set.
"'" (single quote) becomes '&#039;' (or &apos;) only when ENT_QUOTES is set.
'<' (less than) becomes '&lt;'
'>' (greater than) becomes '&gt;'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top