- urldecode: documentation ( source)
- htmlspecialchars: documentation ( source)
<?php
//echo htmlspecialchars(html_entity_decode(html_entity_decode('Bob&#39;s dog', ENT_QUOTES), ENT_QUOTES), ENT_QUOTES);
echo htmlspecialchars(urldecode('Bob&#39;s dog'), ENT_QUOTES);