htmlspecialchars � Convert special characters to HTML entities
htmlentities � Convert all applicable characters to HTML entities
htmlentities
PHP CODE:<?php
$str = "A 'quote' is <b>bold</b>";
echo htmlentities($str);
echo htmlentities($str, ENT_QUOTES);
?>
$str = "A 'quote' is <b>bold</b>";
echo htmlentities($str);
echo htmlentities($str, ENT_QUOTES);
?>
OUTPUT
A 'quote' is <b>bold</b>
A 'quote' is <b>bold</b>
A 'quote' is <b>bold</b>
htmlspecialchars
PHP CODE:<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; //
?>
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; //
?>
OUTPUT
<a href='test'>Test</a>