*htmlentities* -- Convert all applicable characters to HTML entities

  string htmlentities(string string [, int flags [, string charset [, bool double_encode]]])~

This function is identical to |htmlspecialchars| in all ways, except with
|htmlentities|, all characters which have HTML character entity equivalents
are translated into these entities.

If you're wanting to decode instead (the reverse) you can use
|html_entity_decode|.

{string} The input string.

{flags} Like |htmlspecialchars|, the optional second {flags} parameter lets
you define what will be done with 'single' and "double" quotes. It takes on
one of three constants with the default being ENT_COMPAT, optionally combined
with a fourth ENT_IGNORE (since PHP 5.3.0): Available {flags} constants
Constant Name Description ENT_COMPAT Will convert double-quotes and leave
single-quotes alone. ENT_QUOTES Will convert both double and single quotes.
ENT_NOQUOTES Will leave both double and single quotes unconverted. ENT_IGNORE
Silently discard invalid code unit sequences instead of returning an empty
string. Added in PHP 5.3.0. This is provided for backwards compatibility;
avoid using it as it may have security implications.

{charset} Like |htmlspecialchars|, it takes an optional third argument
{charset} which defines character set used in conversion. Presently, the
ISO-8859-1 character set is used as the default.

&reference.strings.charsets; {double_encode} When {double_encode} is turned
off PHP will not encode existing html entities. The default is to convert
everything.

Returns the encoded string.

Version Description 5.3.0 The constant ENT_IGNORE was added. 5.2.3 The
{double_encode} parameter was added. 4.1.0 The {charset} parameter was added.
4.0.3 The {flags} parameter was added.

A |htmlentities| example

<?php >
  $str = "A 'quote' is <b>bold</b>";
  
  // Outputs: A 'quote' is <b>bold</b>
  echo htmlentities($str);
  
  // Outputs: A &amp;#039;quote&amp;#039; is <b>bold</b>
  echo htmlentities($str, ENT_QUOTES);
?>





Usage of ENT_IGNORE

<?php >
  $str = "\x8F!!!";
  
  // Outputs an empty string
  echo htmlentities($str, ENT_QUOTES, "UTF-8");
  
  // Outputs "!!!"
  echo htmlentities($str, ENT_QUOTES | ENT_IGNORE, "UTF-8");
?>





|html_entity_decode| |get_html_translation_table| |htmlspecialchars| |nl2br|
|urlencode|

vim:ft=help:
