PHP function of the day: html_entity_decode()

For day 8 of 21 in the “PHP Function of the day” series, I’m going to look at html_entity_decode().  It takes HTML entities and converts them to HTML.

Let’s take a look.


$html = ‘<h1>Hello!</h1><p>Joe\’s website is at: <a href=””></a></p>’;

$encoded = htmlentities($html);

echo $encoded.'<br />’;

echo html_entity_decode($encoded);



See the output


As you can see, this effectively reverses the output of htmlentities() from yesterday’s post.

Leave a Reply

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