mirror of
https://github.com/php/doc-zh.git
synced 2026-03-26 08:02:16 +01:00
* Update quoted-printable-encode.xml * Update htmlspecialchars-decode.xml * Update str-repeat.xml * Update substr-replace.xml * Update levenshtein.xml * Update utf8-decode.xml * Update htmlspecialchars-decode.xml * Update levenshtein.xml * Update substr-replace.xml * Update utf8-decode.xml
199 lines
5.5 KiB
XML
199 lines
5.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- $Revision$ -->
|
||
<!-- EN-Revision: eabde0419cf90f596f60db00e31fcb6ebe41ac55 Maintainer: daijie Status: ready -->
|
||
<!-- CREDITS: mowangjuanzi -->
|
||
<refentry xml:id="function.htmlspecialchars-decode" xmlns="http://docbook.org/ns/docbook">
|
||
<refnamediv>
|
||
<refname>htmlspecialchars_decode</refname>
|
||
<refpurpose>
|
||
将特殊的 HTML 实体转换回普通字符
|
||
</refpurpose>
|
||
</refnamediv>
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<methodsynopsis>
|
||
<type>string</type><methodname>htmlspecialchars_decode</methodname>
|
||
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
||
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</initializer></methodparam>
|
||
</methodsynopsis>
|
||
|
||
<para>
|
||
此函数的作用和 <function>htmlspecialchars</function> 刚好相反。它将特殊的HTML实体转换回普通字符。
|
||
</para>
|
||
<para>
|
||
被转换的实体有: <literal>&amp;</literal>,
|
||
<literal>&quot;</literal> (没有设置<constant>ENT_NOQUOTES</constant> 时),
|
||
<literal>&#039;</literal> (设置了 <constant>ENT_QUOTES</constant> 时),
|
||
<literal>&lt;</literal> 以及<literal>&gt;</literal>。
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>string</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
要解码的字符串
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>flags</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
用下列标记中的一个或多个作为一个位掩码,来指定如何处理引号和使用哪种文档类型。默认为 <literal>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</literal>。
|
||
<table>
|
||
<title>有效的 <parameter>flags</parameter> 常量</title>
|
||
<tgroup cols="2">
|
||
<thead>
|
||
<row>
|
||
<entry>常量名</entry>
|
||
<entry>说明</entry>
|
||
</row>
|
||
</thead>
|
||
<tbody>
|
||
<row>
|
||
<entry><constant>ENT_COMPAT</constant></entry>
|
||
<entry>转换双引号,不转换单引号。</entry>
|
||
</row>
|
||
<row>
|
||
<entry><constant>ENT_QUOTES</constant></entry>
|
||
<entry>单引号和双引号都转换。</entry>
|
||
</row>
|
||
<row>
|
||
<entry><constant>ENT_NOQUOTES</constant></entry>
|
||
<entry>单引号和双引号都不转换。</entry>
|
||
</row>
|
||
<row>
|
||
<entry><constant>ENT_SUBSTITUTE</constant></entry>
|
||
<entry>
|
||
使用 Unicode 替换符 U+FFFD (UTF-8) 或 &#xFFFD 替换无效的码区序列(code unit sequence)。而不是返回空字符串。
|
||
</entry>
|
||
</row>
|
||
<row>
|
||
<entry><constant>ENT_HTML401</constant></entry>
|
||
<entry>
|
||
作为HTML 4.01编码处理。
|
||
</entry>
|
||
</row>
|
||
<row>
|
||
<entry><constant>ENT_XML1</constant></entry>
|
||
<entry>
|
||
作为XML 1编码处理。
|
||
</entry>
|
||
</row>
|
||
<row>
|
||
<entry><constant>ENT_XHTML</constant></entry>
|
||
<entry>
|
||
作为XHTML编码处理。
|
||
</entry>
|
||
</row>
|
||
<row>
|
||
<entry><constant>ENT_HTML5</constant></entry>
|
||
<entry>
|
||
作为HTML 5编码处理。
|
||
</entry>
|
||
</row>
|
||
</tbody>
|
||
</tgroup>
|
||
</table>
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
返回解码后的字符串。
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="changelog">
|
||
&reftitle.changelog;
|
||
<informaltable>
|
||
<tgroup cols="2">
|
||
<thead>
|
||
<row>
|
||
<entry>&Version;</entry>
|
||
<entry>&Description;</entry>
|
||
</row>
|
||
</thead>
|
||
<tbody>
|
||
<row>
|
||
<entry>8.1.0</entry>
|
||
<entry>
|
||
<parameter>flags</parameter> 从 <constant>ENT_COMPAT</constant> 变更为<constant>ENT_QUOTES</constant>
|
||
| <constant>ENT_SUBSTITUTE</constant> | <constant>ENT_HTML401</constant>。
|
||
</entry>
|
||
</row>
|
||
</tbody>
|
||
</tgroup>
|
||
</informaltable>
|
||
</refsect1>
|
||
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<para>
|
||
<example>
|
||
<title><function>htmlspecialchars_decode</function> 示例</title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
$str = "<p>this -> "</p>\n";
|
||
|
||
echo htmlspecialchars_decode($str);
|
||
|
||
// 注意,这里的引号不会被转换
|
||
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
&example.outputs;
|
||
<screen>
|
||
<![CDATA[
|
||
<p>this -> "</p>
|
||
<p>this -> "</p>
|
||
]]>
|
||
</screen>
|
||
</example>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="seealso">
|
||
&reftitle.seealso;
|
||
<para>
|
||
<simplelist>
|
||
<member><function>htmlspecialchars</function></member>
|
||
<member><function>html_entity_decode</function></member>
|
||
<member><function>get_html_translation_table</function></member>
|
||
</simplelist>
|
||
</para>
|
||
</refsect1>
|
||
</refentry>
|
||
<!-- Keep this comment at the end of the file
|
||
Local variables:
|
||
mode: sgml
|
||
sgml-omittag:t
|
||
sgml-shorttag:t
|
||
sgml-minimize-attributes:nil
|
||
sgml-always-quote-attributes:t
|
||
sgml-indent-step:1
|
||
sgml-indent-data:t
|
||
indent-tabs-mode:nil
|
||
sgml-parent-document:nil
|
||
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||
sgml-exposed-tags:nil
|
||
sgml-local-catalogs:nil
|
||
sgml-local-ecat-files:nil
|
||
End:
|
||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
vim: et tw=78 syn=sgml
|
||
vi: ts=1 sw=1
|
||
-->
|