Document htmlentities/htmlspecialchars quote handling

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@32571 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Rasmus Lerdorf 2000-09-12 17:36:56 +00:00
parent 2c4588886e
commit 8a30b62aeb

View file

@ -576,16 +576,21 @@ $pieces = explode (" ", $pizza);
<function>get_html_translation_table</function>
</funcdef>
<paramdef>int <parameter>table</parameter></paramdef>
<paramdef>int <parameter><optional>quote_style</optional></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>get_html_translation_table</function> will return the
translation table that is used internally for
<function>htmlspecialchars</function> and
<function>htmlentities</function>. Ther are two new defines
<function>htmlentities</function>. There are two new defines
(<parameter>HTML_ENTITIES</parameter>,
<parameter>HTML_SPECIALCHARS</parameter>) that allow you to
specify the table you want.
specify the table you want. And as in the
<function>htmlspecialchars</function> and
<function>htmlentities</function> functions you can optionally specify the
quote_style you are working with. The default is ENT_COMPAT mode. See
the description of these modes in <function>htmlspecialchars</function>.
<example>
<title>Translation Table Example</title>
<programlisting role="php">
@ -745,13 +750,19 @@ $original = strtr ($str, $trans);
<funcprototype>
<funcdef>string <function>htmlentities</function></funcdef>
<paramdef>string <parameter>string</parameter></paramdef>
<paramdef>int <parameter><optional>quote_style</optional></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function is identical to
<function>htmlspecialchars</function> in all ways, except that
all characters which have HTML character entity equivalents are
translated into these entities.
translated into these entities. Like htmlspecialchars(), it takes an
optional second argument which indicates what should be done with
single and double quotes. ENT_COMPAT (the default) will only convert
double-quotes and leave single-quotes alone. ENT_QUOTES will convert
both double and single quotes, and ENT_NOQUOTES will leave both double
and single quotes unconverted.
</para>
<para>
At present, the ISO-8859-1 character set is used.
@ -776,13 +787,14 @@ $original = strtr ($str, $trans);
<funcprototype>
<funcdef>string <function>htmlspecialchars</function></funcdef>
<paramdef>string <parameter>string</parameter></paramdef>
<paramdef>int <parameter><optional>quote_style</optional></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Certain characters have special significance in HTML, and should
be represented by HTML entities if they are to preserve their
meanings. This function returns a string with some of these
conversions made; the four translations made are those most
conversions made; the translations made are those most
useful for everyday web programming. If you require all HTML
character entities to be translated, use
<function>htmlentities</function> instead.
@ -790,7 +802,13 @@ $original = strtr ($str, $trans);
<simpara>
This function is useful in preventing user-supplied text from
containing HTML markup, such as in a message board or guest book
application.
application. The optional second argument, quote_style, tells the
function what to do with single and double quote characters. The
default mode, ENT_COMPAT, is the backwards compatible mode which only
translates the double-quote character and leaves the single-quote
untranslated. If ENT_QUOTES is set, both single and double quotes
are translated and if ENT_NOQUOTES is set neither single nor double quotes
are translated.
</simpara>
<para>
The translations performed are:
@ -802,7 +820,12 @@ $original = strtr ($str, $trans);
</listitem>
<listitem>
<simpara>
'&quot;' (double quote) becomes '&amp;quot;'
'&quot;' (double quote) becomes '&amp;quot;' when ENT_NOQUOTES is not set.
</simpara>
</listitem>
<listitem>
<simpara>
'&#039;' (single quote) becomes '&amp;#039;' only when ENT_QUOTES is set.
</simpara>
</listitem>
<listitem>
@ -816,6 +839,12 @@ $original = strtr ($str, $trans);
</simpara>
</listitem>
</itemizedlist>
<example>
<title><function>htmlspecialchars</function> example</title>
<programlisting role="php">
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
</programlisting>
</example>
</para>
<para>
Note that this functions does not translate anything beyond what