function.get-html-translation-table.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 139 行
HTML
139 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Returns the translation table used by htmlspecialchars and htmlentities</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.fprintf.html">fprintf</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.hebrev.html">hebrev</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><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)</p><p class="refpurpose"><span class="refname">get_html_translation_table</span> — <span class="dc-title">Returns the translation table used by <a href="function.htmlspecialchars.html" class="function">htmlspecialchars()</a> and <a href="function.htmlentities.html" class="function">htmlentities()</a></span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>get_html_translation_table</b></b></span> ([ <span class="methodparam"><span class="type">int</span> <tt class="parameter">$table</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$quote_style</tt></span> ]] )</div> <p class="para rdfs-comment"> <b>get_html_translation_table()</b> will return the translation table that is used internally for <a href="function.htmlspecialchars.html" class="function">htmlspecialchars()</a> and <a href="function.htmlentities.html" class="function">htmlentities()</a>. </p> <blockquote><p><b class="note">Note</b>: Special characters can be encoded in several ways. E.g. <i>"</i> can be encoded as <i>&quot;</i>, <i>&#34;</i> or <i>&#x22</i>. <b>get_html_translation_table()</b> returns only the most common form for them. <br /> </p></blockquote> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">table</tt></i></span> <dd> <p class="para"> There are two new constants (<b><tt>HTML_ENTITIES</tt></b>, <b><tt>HTML_SPECIALCHARS</tt></b>) that allow you to specify the table you want. Default value for <i><tt class="parameter">table</tt></i> is <b><tt>HTML_SPECIALCHARS</tt></b>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">quote_style</tt></i></span> <dd> <p class="para"> Like the <a href="function.htmlspecialchars.html" class="function">htmlspecialchars()</a> and <a href="function.htmlentities.html" class="function">htmlentities()</a> functions you can optionally specify the <i><tt class="parameter">quote_style</tt></i> you are working with. The default is <b><tt>ENT_COMPAT</tt></b> mode. See the description of these modes in <a href="function.htmlspecialchars.html" class="function">htmlspecialchars()</a>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the translation table as an array. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Translation Table Example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$trans </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">);<br /></span><span style="color: #0000BB">$str </span><span style="color: #007700">= </span><span style="color: #DD0000">"Hallo & <Frau> & Kr盲mer"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$encoded </span><span style="color: #007700">= </span><span style="color: #0000BB">strtr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #0000BB">$trans</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> The <i>$encoded</i> variable will now contain: <i>"Hallo &amp; &lt;Frau&gt; &amp; Kr&auml;mer".</i> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.htmlspecialchars.html" class="function" rel="rdfs-seeAlso">htmlspecialchars()</a></li> <li class="member"><a href="function.htmlentities.html" class="function" rel="rdfs-seeAlso">htmlentities()</a></li> <li class="member"><a href="function.html-entity-decode.html" class="function" rel="rdfs-seeAlso">html_entity_decode()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.fprintf.html">fprintf</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.hebrev.html">hebrev</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?