htmlentities
Convert all applicable characters to HTML entities
$str = "A 'quote' is <b>bold</b>";
Example
echo htmlentities($str);
// Outputs: A 'quote' is <b>bold</b>
htmlspecialchars
Convert special characters to HTML entities
'&' (ampersand) becomes '&'
'<' (less than) becomes '<'
Example
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; //Outputs: <a href='test'>Test</a>
Convert all applicable characters to HTML entities
$str = "A 'quote' is <b>bold</b>";
Example
echo htmlentities($str);
// Outputs: A 'quote' is <b>bold</b>
htmlspecialchars
Convert special characters to HTML entities
'&' (ampersand) becomes '&'
'<' (less than) becomes '<'
Example
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; //Outputs: <a href='test'>Test</a>
No comments:
Post a Comment