Converts characters to html entities.
Characters that may not be displayed correctly in the character set used, should be encoded as html entities. htmlentities() replaces such characters in a string with their corresponding html entities. A new translated string is returned. The quote_style parameter specifies whether quotes should be escaped. The possible values for quote_style are ENT_COMPAT, which only escapes double quotes, ENT_NOQUOTES, for no quote escaping, and ENT_QUOTES for escaping both double and single quotes. The characterset parameter specifies a character set to use for the translation. Default is ISO-8859-1.
<?php
$s = '"Foreign" letters often cause trouble: éèôåäö';
print htmlspecialchars(htmlentities($s, ENT_NOQUOTES), ENT_NOQUOTES);
?>
"Foreign" letters often cause trouble: éèôåäö
A number of non-English characters are converted to their corresponding html entities. htmlspecialchars() is used on the result so that the contents of the string may be examined.