- htmlentities: documentation ( source)
- html_entity_decode: documentation ( source)
<?php
$encoded = htmlentities("Hey I am a nefarious hacker! Look at my brackets! <script>HAHAHA</script>!");
$decoded = html_entity_decode($encoded);
echo "htmlentities makes the text from the comment box safe to put in HTML source code. \n";
echo $encoded;
echo "\n\nLike the user's web browser will do automatically, html_entity_decode makes it look normal again.\n";
echo $decoded;
?>