htmlspecialchars() – Convert some special characters to HTML entities (Only the most widely used)
htmlentities() – Convert ALL special characters to HTML entities
htmlspecialchars — Convert special characters to HTML entities
htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand.
htmlentities() – Convert ALL special characters to HTML entities
<?php
$str = "A 'quote' is <b>bold</b>";
echo htmlentities($str);
echo htmlentities($str, ENT_QUOTES);
?>
htmlspecialchars — Convert special characters to HTML entities
htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand.
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new;
?>
No comments:
Post a Comment