svn: /phpdoc/en/trunk/reference/strings/functions/ htmlentities.xml htmlspecialchars.xml
| From: | Gustavo André dos Santos Lopes | Date: | Mon, 11 Oct 2010 01:15:45 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/strings/functions/ htmlentities.xml htmlspecialchars.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-7203@lists.php.net to get a copy of this message | ||
cataphract Mon, 11 Oct 2010 01:15:45 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=304297
Log:
- Documented addition of ENT_IGNORE as per bug #43896
(changed its status from TBD to Closed).
Bug: http://bugs.php.net/43896 (To be documented)
htmlspecialchars() returns empty string on invalid unicode sequence
Changed paths:
U phpdoc/en/trunk/reference/strings/functions/htmlentities.xml
U phpdoc/en/trunk/reference/strings/functions/htmlspecialchars.xml
Modified: phpdoc/en/trunk/reference/strings/functions/htmlentities.xml
===================================================================
--- phpdoc/en/trunk/reference/strings/functions/htmlentities.xml 2010-10-11 00:17:51 UTC (rev
304296)
+++ phpdoc/en/trunk/reference/strings/functions/htmlentities.xml 2010-10-11 01:15:45 UTC (rev
304297)
@@ -11,7 +11,7 @@
<methodsynopsis>
<type>string</type><methodname>htmlentities</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
- <methodparam
choice="opt"><type>int</type><parameter>quote_style</parameter><initializer>ENT_COMPAT</initializer></methodparam>
+ <methodparam
choice="opt"><type>int</type><parameter>flags</parameter><initializer>ENT_COMPAT</initializer></methodparam>
<methodparam
choice="opt"><type>string</type><parameter>charset</parameter></methodparam>
<methodparam
choice="opt"><type>bool</type><parameter>double_encode</parameter><initializer>true</initializer></methodparam>
</methodsynopsis>
@@ -39,15 +39,17 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><parameter>quote_style</parameter></term>
+ <term><parameter>flags</parameter></term>
<listitem>
<para>
Like <function>htmlspecialchars</function>, the optional second
- <parameter>quote_style</parameter> parameter lets you define what will
+ <parameter>flags</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>:
+ constants with the default being <constant>ENT_COMPAT</constant>,
+ optionally combined with a fourth <constant>ENT_IGNORE</constant> (since
+ PHP 5.3.0):
<table>
- <title>Available <parameter>quote_style</parameter>
constants</title>
+ <title>Available <parameter>flags</parameter> constants</title>
<tgroup cols="2">
<thead>
<row>
@@ -68,6 +70,13 @@
<entry><constant>ENT_NOQUOTES</constant></entry>
<entry>Will leave both double and single quotes unconverted.</entry>
</row>
+ <row>
+ <entry><constant>ENT_IGNORE</constant></entry>
+ <entry>
+ Silently discard invalid code unit sequences instead of returning
+ an empty string. Added in PHP 5.3.0.
+ </entry>
+ </row>
</tbody>
</tgroup>
</table>
@@ -119,6 +128,12 @@
</thead>
<tbody>
<row>
+ <entry>5.3.0</entry>
+ <entry>
+ The constant <constant>ENT_IGNORE</constant> was added.
+ </entry>
+ </row>
+ <row>
<entry>5.2.3</entry>
<entry>
The <parameter>double_encode</parameter> parameter was added.
@@ -133,7 +148,7 @@
<row>
<entry>4.0.3</entry>
<entry>
- The <parameter>quote_style</parameter> parameter was added.
+ The <parameter>flags</parameter> parameter was added.
</entry>
</row>
</tbody>
@@ -162,6 +177,25 @@
</programlisting>
</example>
</para>
+
+ <para>
+ <example>
+ <title>Usage of <constant>ENT_IGNORE</constant></title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$str = "\x8F!!!";
+
+// Outputs an empty string
+echo htmlspecialchars("\x8F!!!", ENT_QUOTES, "UTF-8");
+
+// Outputs "!!!"
+echo htmlspecialchars("\x8F!!!", ENT_QUOTES | ENT_IGNORE, "UTF-8");
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
</refsect1>
<refsect1 role="seealso">
Modified: phpdoc/en/trunk/reference/strings/functions/htmlspecialchars.xml
===================================================================
--- phpdoc/en/trunk/reference/strings/functions/htmlspecialchars.xml 2010-10-11 00:17:51 UTC (rev
304296)
+++ phpdoc/en/trunk/reference/strings/functions/htmlspecialchars.xml 2010-10-11 01:15:45 UTC (rev
304297)
@@ -11,7 +11,7 @@
<methodsynopsis>
<type>string</type><methodname>htmlspecialchars</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
- <methodparam
choice="opt"><type>int</type><parameter>quote_style</parameter><initializer>ENT_COMPAT</initializer></methodparam>
+ <methodparam
choice="opt"><type>int</type><parameter>flags</parameter><initializer>ENT_COMPAT</initializer></methodparam>
<methodparam
choice="opt"><type>string</type><parameter>charset</parameter></methodparam>
<methodparam
choice="opt"><type>bool</type><parameter>double_encode</parameter><initializer>true</initializer></methodparam>
</methodsynopsis>
@@ -76,16 +76,21 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><parameter>quote_style</parameter></term>
+ <term><parameter>flags</parameter></term>
<listitem>
<para>
- The optional second argument, <parameter>quote_style</parameter>, tells
- the function what to do with single and double quote characters.
+ The optional second argument, <parameter>flags</parameter>, tells
+ the function what to do with single and double quote characters and with
+ invalid multi-byte sequences.
The default mode, <constant>ENT_COMPAT</constant>, is the backwards compatible
mode
which only translates the double-quote character and leaves the
single-quote untranslated. If <constant>ENT_QUOTES</constant> is set, both
single and
double quotes are translated and if <constant>ENT_NOQUOTES</constant> is set
neither
single nor double quotes are translated.
+ In addition, since 5.3.0, these constants can be combined with
+ <constant>ENT_IGNORE</constant>. In that case, strings that contain invalid code
unit
+ sequences have those invalid sequences discarded instead of having the function
+ return an empty string.
</para>
</listitem>
</varlistentry>