PHP htmlspecialchars_decode() Function

The htmlspecialchars_decode() function converts some predefined HTML entities to characters. The htmlspecialchars_decode() function is the opposite of htmlspecialchars(). You may also like PHP html_entity_decode() Function and How to Encode and Decode URL Using PHP.


$str = "This is some &lt;b&gt;bold&lt;/b&gt; text.";
echo htmlspecialchars_decode($str);

The HTML output of the code above will be (View Source):

<!DOCTYPE html>
This is some <b>bold</b> text.


This is some bold text.

Leave a Reply

Your email address will not be published. Required fields are marked *