htmlentities — Convert all applicable characters to HTML entities
<?php
$str = "A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities style="color: #007700;">($str, ENT_QUOTES);
?>htmlspecialchars much should i take — Convert special characters to HTML entities
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // <a href='test'>Test</a>
?> 
Comments