mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Moved constants to a table, removed the unentities() example and refer to
html_entity_decode() instead. A basic rewrite of the docs. See also urlencode() and html_entity_decode(). git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@104691 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
6bb0c789a0
commit
bb9cff0e20
1 changed files with 45 additions and 34 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.htmlentities">
|
||||
<refnamediv>
|
||||
|
@ -18,49 +18,60 @@
|
|||
</methodsynopsis>
|
||||
<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. Like
|
||||
<function>htmlspecialchars</function>, it takes an optional
|
||||
second argument which indicates what should be done with single
|
||||
and double quotes. <constant>ENT_COMPAT</constant> (the default)
|
||||
will only convert double-quotes and leave single-quotes alone.
|
||||
<constant>ENT_QUOTES</constant> will convert both double and
|
||||
single quotes, and <constant>ENT_NOQUOTES</constant> will leave
|
||||
both double and single quotes unconverted.
|
||||
<function>htmlspecialchars</function> in all ways, except with
|
||||
<function>htmlentities</function>, all characters which have HTML
|
||||
character entity equivalents are translated into these entities.
|
||||
</para>
|
||||
<para>
|
||||
At present, the ISO-8859-1 character set is used as default.
|
||||
Support for the optional second argument was added in PHP 3.0.17 and PHP
|
||||
4.0.3.
|
||||
Like <function>htmlspecialchars</function>, the optional second
|
||||
<parameter>quote_style</parameter> parameter lets you define what will
|
||||
be done with 'single' and "double" quotes. It takes on one of three
|
||||
constants with the default being <constant>ENT_COMPAT</constant>:
|
||||
<table>
|
||||
<title>Available <parameter>quote_style</parameter> constants</title>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Constant Name</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><constant>END_COMPAT</constant></entry>
|
||||
<entry>Will convert double-quotes and leave single-quotes alone.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><constant>ENT_QUOTES</constant></entry>
|
||||
<entry>Will convert both double and single quotes.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><constant>END_NOQUOTES</constant></entry>
|
||||
<entry>Will leave both double and single quotes unconverted.</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
<para>
|
||||
Support for the optional <parameter>quote</parameter> parameter was
|
||||
added in PHP 4.0.3.
|
||||
</para>
|
||||
<para>
|
||||
Like <function>htmlspecialchars</function>, it takes an optional
|
||||
third argument which defines character set used in conversion.
|
||||
Support for this argument was added in PHP 4.1.0.
|
||||
Support for this argument was added in PHP 4.1.0. Presently, the
|
||||
ISO-8859-1 character set is used as the default.
|
||||
</para>
|
||||
<para>
|
||||
There is no reverse of this function. However, you can create one on your
|
||||
own. Here is an example of how to do this.
|
||||
If you're wanting to decode instead (the reverse) you can use
|
||||
<function>html_entity_decode</function>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Reverse of <function>htmlentities</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function unhtmlentities ($string)
|
||||
{
|
||||
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
|
||||
$trans_tbl = array_flip ($trans_tbl);
|
||||
return strtr ($string, $trans_tbl);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
See also <function>get_html_translation_table</function>,
|
||||
<function>htmlspecialchars</function> and <function>nl2br</function>.
|
||||
See also <function>html_entity_decode</function>,
|
||||
<function>get_html_translation_table</function>,
|
||||
<function>htmlspecialchars</function>, <function>nl2br</function>,
|
||||
and <function>urlencode</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
|
Loading…
Reference in a new issue