cvs: phpdoc /en/reference/strings/functions htmlentities.xml

From: Date: Mon, 18 Nov 2002 10:20:52 +0000
Subject: cvs: phpdoc /en/reference/strings/functions htmlentities.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969349769@lists.php.net to get a copy of this message
philip Mon Nov 18 05:20:52 2002 EDT Modified files: /phpdoc/en/reference/strings/functions htmlentities.xml Log: 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(). Index: phpdoc/en/reference/strings/functions/htmlentities.xml diff -u phpdoc/en/reference/strings/functions/htmlentities.xml:1.6 phpdoc/en/reference/strings/functions/htmlentities.xml:1.7 --- phpdoc/en/reference/strings/functions/htmlentities.xml:1.6 Sat Aug 10 06:59:47 2002 +++ phpdoc/en/reference/strings/functions/htmlentities.xml Mon Nov 18 05:20:52 2002 @@ -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>

« previous php.doc (#969349769) next »