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.
<?php
$html = ‘<h1>Hello!</h1><p>Joe\’s website is at: <a href=”https://jws.dev”>jws.dev</a></p>’;
$encoded = htmlentities($html);
echo $encoded.'<br />’;
echo html_entity_decode($encoded);
?>
As you can see, this effectively reverses the output of htmlentities() from yesterday’s post.