mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 22:06:57 +08:00
402 lines
12 KiB
HTML
402 lines
12 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
<title>返回使用 htmlspecialchars 和 htmlentities 后的转换表</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.get-html-translation-table" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">get_html_translation_table</h1>
|
||
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">get_html_translation_table</span> — <span class="dc-title">返回使用 <span class="function"><a href="htmlspecialchars.html" class="function">htmlspecialchars()</a></span> 和 <span class="function"><a href="htmlentities.html" class="function">htmlentities()</a></span> 后的转换表</span></p>
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.get-html-translation-table-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>get_html_translation_table</strong></span>
|
||
([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$table</code><span class="initializer"> = HTML_SPECIALCHARS</span></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = ENT_COMPAT | ENT_HTML401</span></span>
|
||
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$encoding</code><span class="initializer"> = 'UTF-8'</span></span>
|
||
]]] ) : <span class="type">array</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
<span class="function"><strong>get_html_translation_table()</strong></span> 将返回 <span class="function"><a href="htmlspecialchars.html" class="function">htmlspecialchars()</a></span> 和
|
||
<span class="function"><a href="htmlentities.html" class="function">htmlentities()</a></span> 处理后的转换表。
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
特殊字符可以使用多种转换方式。 例如:
|
||
<em>"</em> 可以被转换成 <em>&quot;</em>,
|
||
<em>&#34;</em> 或者 <em>&#x22</em>.
|
||
<span class="function"><strong>get_html_translation_table()</strong></span> 返回其中最常用的。
|
||
</p>
|
||
</p></blockquote>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.get-html-translation-table-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">table</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
有两个新的常量 (<strong><code>HTML_ENTITIES</code></strong>,
|
||
<strong><code>HTML_SPECIALCHARS</code></strong>) 允许你指定你想要的表。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">flags</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
A bitmask of one or more of the following flags, which specify which quotes the
|
||
table will contain as well as which document type the table is for. The default is
|
||
<em>ENT_COMPAT | ENT_HTML401</em>.
|
||
<table class="doctable table">
|
||
<caption><strong>Available <code class="parameter">flags</code> constants</strong></caption>
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>Constant Name</th>
|
||
<th>Description</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td><strong><code>ENT_COMPAT</code></strong></td>
|
||
<td>Table will contain entities for double-quotes, but not for single-quotes.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><strong><code>ENT_QUOTES</code></strong></td>
|
||
<td>Table will contain entities for both double and single quotes.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><strong><code>ENT_NOQUOTES</code></strong></td>
|
||
<td>Table will neither contain entities for single quotes nor for double quotes.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><strong><code>ENT_HTML401</code></strong></td>
|
||
<td>Table for HTML 4.01.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><strong><code>ENT_XML1</code></strong></td>
|
||
<td>Table for XML 1.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><strong><code>ENT_XHTML</code></strong></td>
|
||
<td>Table for XHTML.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><strong><code>ENT_HTML5</code></strong></td>
|
||
<td>Table for HTML 5.</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">encoding</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Encoding to use.
|
||
If omitted, the default value for this argument is ISO-8859-1 in
|
||
versions of PHP prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.
|
||
</p>
|
||
|
||
|
||
|
||
<p class="para">
|
||
支持以下字符集:
|
||
<table class="doctable table">
|
||
<caption><strong>支持的字符集列表</strong></caption>
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>字符集</th>
|
||
<th>别名</th>
|
||
<th>描述</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td>ISO-8859-1</td>
|
||
<td>ISO8859-1</td>
|
||
<td>
|
||
西欧,Latin-1
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>ISO-8859-5</td>
|
||
<td>ISO8859-5</td>
|
||
<td>
|
||
Little used cyrillic charset (Latin/Cyrillic).
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>ISO-8859-15</td>
|
||
<td>ISO8859-15</td>
|
||
<td>
|
||
西欧,Latin-9。增加欧元符号,法语和芬兰语字母在 Latin-1(ISO-8859-1) 中缺失。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>UTF-8</td>
|
||
<td class="empty"> </td>
|
||
<td>
|
||
ASCII 兼容的多字节 8 位 Unicode。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>cp866</td>
|
||
<td>ibm866, 866</td>
|
||
<td>
|
||
DOS 特有的西里尔编码。本字符集在 4.3.2 版本中得到支持。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>cp1251</td>
|
||
<td>Windows-1251, win-1251, 1251</td>
|
||
<td>
|
||
Windows 特有的西里尔编码。本字符集在 4.3.2 版本中得到支持。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>cp1252</td>
|
||
<td>Windows-1252, 1252</td>
|
||
<td>
|
||
Windows 特有的西欧编码。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>KOI8-R</td>
|
||
<td>koi8-ru, koi8r</td>
|
||
<td>
|
||
俄语。本字符集在 4.3.2 版本中得到支持。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>BIG5</td>
|
||
<td>950</td>
|
||
<td>
|
||
繁体中文,主要用于中国台湾省。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>GB2312</td>
|
||
<td>936</td>
|
||
<td>
|
||
简体中文,中国国家标准字符集。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>BIG5-HKSCS</td>
|
||
<td class="empty"> </td>
|
||
<td>
|
||
繁体中文,附带香港扩展的 Big5 字符集。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>Shift_JIS</td>
|
||
<td>SJIS, 932</td>
|
||
<td>
|
||
日语
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>EUC-JP</td>
|
||
<td>EUCJP</td>
|
||
<td>
|
||
日语
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>MacRoman</td>
|
||
<td class="empty"> </td>
|
||
<td>
|
||
Mac OS 使用的字符串。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>''</em></td>
|
||
<td class="empty"> </td>
|
||
<td>
|
||
An empty string activates detection from script encoding (Zend multibyte),
|
||
<a href="ini.core.html#ini.default-charset" class="link">default_charset</a> and current
|
||
locale (see <span class="function"><a href="nl_langinfo.html" class="function">nl_langinfo()</a></span> and
|
||
<span class="function"><a href="setlocale.html" class="function">setlocale()</a></span>), in this order. Not recommended.
|
||
</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<span class="simpara">
|
||
其他字符集没有认可。将会使用默认编码并抛出异常。
|
||
</span>
|
||
</p></blockquote>
|
||
</p>
|
||
|
||
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.get-html-translation-table-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
将转换表作为一个数组返回。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 changelog" id="refsect1-function.get-html-translation-table-changelog">
|
||
<h3 class="title">更新日志</h3>
|
||
<p class="para">
|
||
<table class="doctable informaltable">
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>版本</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td>5.4.0</td>
|
||
<td>
|
||
The default value for the <code class="parameter">encoding</code> parameter was
|
||
changed to UTF-8.
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>5.4.0</td>
|
||
<td>
|
||
The constants <strong><code>ENT_HTML401</code></strong>, <strong><code>ENT_XML1</code></strong>,
|
||
<strong><code>ENT_XHTML</code></strong> and <strong><code>ENT_HTML5</code></strong> were added.
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>5.3.4</td>
|
||
<td>
|
||
The <code class="parameter">encoding</code> parameter was added.
|
||
</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.get-html-translation-table-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-5908">
|
||
<p><strong>Example #1 Translation Table Example</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_html_translation_table</span><span style="color: #007700">(</span><span style="color: #0000BB">HTML_ENTITIES</span><span style="color: #007700">, </span><span style="color: #0000BB">ENT_QUOTES </span><span style="color: #007700">| </span><span style="color: #0000BB">ENT_HTML5</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
|
||
<div class="example-contents screen">
|
||
<div class="cdata"><pre>
|
||
array(1510) {
|
||
["
|
||
"]=>
|
||
string(9) "&NewLine;"
|
||
["!"]=>
|
||
string(6) "&excl;"
|
||
["""]=>
|
||
string(6) "&quot;"
|
||
["#"]=>
|
||
string(5) "&num;"
|
||
["$"]=>
|
||
string(8) "&dollar;"
|
||
["%"]=>
|
||
string(8) "&percnt;"
|
||
["&"]=>
|
||
string(5) "&amp;"
|
||
["'"]=>
|
||
string(6) "&apos;"
|
||
// ...
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.get-html-translation-table-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="htmlspecialchars.html" class="function" rel="rdfs-seeAlso">htmlspecialchars()</a> - 将特殊字符转换为 HTML 实体</span></li>
|
||
<li class="member"><span class="function"><a href="htmlentities.html" class="function" rel="rdfs-seeAlso">htmlentities()</a> - 将字符转换为 HTML 转义字符</span></li>
|
||
<li class="member"><span class="function"><a href="html_entity_decode.html" class="function" rel="rdfs-seeAlso">html_entity_decode()</a> - Convert HTML entities to their corresponding characters</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
</div></div></div></body></html> |