Php/func string get html translation table

来自菜鸟教程
跳转至:导航、​搜索

PHP get_html_translation_table()函数

❮PHP字符串参考

打印htmlspecialchars函数使用的翻译表:

 <?php

print_r (get_html_translation_table()); // HTML_SPECIALCHARS is default.

 ?>

定义和用法

get_html_translation_table()函数返回翻译表使用的翻译表。 htmlentities()

and htmlspecialchars()

功能。

Tip: 某些字符可以几种方式编码。get_html_translation_table()函数返回最常用的编码。

句法

get_html_translation_table(function,flags,character-set)

参数值

参数 描述
function

可选的。指定要返回的转换表。 可能的值:

  • HTML_SPECIALCHARS-默认。翻译一些需要URL编码才能在HTML页面上正确显示的字符
  • HTML_ENTITIES-翻译所有需要URL编码才能在HTML页面上正确显示的字符
flags

可选的。指定表将包含哪些引号以及该表适用于哪种文档类型。 可用的引用样式为:

  • ENT_COMPAT-默认。该表包含双引号而不是单引号的实体
  • ENT_QUOTES-表包含双引号和单引号的实体
  • ENT_NOQUOTES-表将不包含双引号和单引号的实体

用于指定表用于哪种文档类型的其他标志:

  • ENT_HTML401-默认。HTML 4.01表格
  • ENT_HTML5-HTML 5表格
  • ENT_XML1-XML 1表
  • ENT_XHTML-XHTML表格
character-set

可选的。一个字符串,指定要使用的字符集。 允许的值为:

  • UTF-8-默认。ASCII兼容的多字节8位Unicode
  • ISO-8859-1-西欧
  • ISO-8859-15-西欧(添加ISO-8859-1中缺少的欧元符号+法语和芬兰字母)
  • cp866-DOS特定的西里尔字符集
  • cp1251-Windows特定的西里尔字符集
  • cp1252-Windows特定于西欧的字符集
  • KOI8-R-俄语
  • BIG5-繁体中文,主要在台湾使用
  • GB2312-简体中文,国家标准字符集
  • BIG5-HKSCS-具有香港扩展名的Big5
  • Shift_JIS-日语
  • EUC-JP-日语
  • MacRoman-Mac OS使用的字符集

注意: 在PHP 5.4之前的版本中,无法识别的字符集将被忽略并由ISO-8859-1代替。从PHP 5.4开始,它将被UTF-8取代。

技术细节

返回值: 以数组的形式返回转换表,原始字符为键,实体为值
PHP版本: 4+
更新日志: 的默认值

character-set 参数已在PHP 5中更改为UTF-8

用于指定表所针对的文档类型的其他标志;在PHP 5.4中添加了ENT_HTML401,ENT_HTML5,ENT_XML1和ENT_XHTML

The character-set 参数已在PHP 5.3.4中添加

更多例子

HTML_SPECIALCHARS的表:

 <?php

print_r (get_html_translation_table(HTML_SPECIALCHARS));

 ?>

显示字符和实体名称:

 Array

 (

   ["] => &quot;

   [&] => &amp;

   [<] => &lt;

   [>] => &gt;

 )



HTML_ENTITIES表:

<?php

print_r (get_html_translation_table(HTML_ENTITIES));

?>

显示字符和实体名称:

 Array

 (

   ["] => &quot;

   [&] => &amp;

   [<] => &lt;

   [>] => &gt;

   [ ] => &nbsp;

   [¡] => &iexcl;

   [¢] => &cent;

   [£] => &pound;

   [¤] => &curren;

   [¥] => &yen;

   [¦] => &brvbar;

   [§] => &sect;

   [¨] => &uml;

   [©] => &copy;

   [ª] => &ordf;

   [«] => &laquo;

   [¬] => &not;

   [­] => &shy;

   [®] => &reg;

   [¯] => &macr;

   [°] => &deg;

   [±] => &plusmn;

   [²] => &sup2;

   [³] => &sup3;

   [´] => &acute;

   [µ] => &micro;

   [¶] => &para;

   [·] => &middot;

   [¸] => &cedil;

   [¹] => &sup1;

   [º] => &ordm;

   [»] => &raquo;

   [¼] => &frac14;

   [½] => &frac12;

   [¾] => &frac34;

   [¿] => &iquest;

   [À] => &Agrave;

   [Á] => &Aacute;

   [Â] => &Acirc;

   [Ã] => &Atilde;

   [Ä] => &Auml;

   [Å] => &Aring;

   [Æ] => &AElig;

   [Ç] => &Ccedil;

   [È] => &Egrave;

   [É] => &Eacute;

   [Ê] => &Ecirc;

   [Ë] => &Euml;

   [Ì] => &Igrave;

   [Í] => &Iacute;

   [Î] => &Icirc;

   [Ï] => &Iuml;

   [Ð] => &ETH;

   [Ñ] => &Ntilde;

   [Ò] => &Ograve;

   [Ó] => &Oacute;

   [Ô] => &Ocirc;

   [Õ] => &Otilde;

   [Ö] => &Ouml;

   [×] => &times;

   [Ø] => &Oslash;

   [Ù] => &Ugrave;

   [Ú] => &Uacute;

   [Û] => &Ucirc;

   [Ü] => &Uuml;

   [Ý] => &Yacute;

   [Þ] => &THORN;

   [ß] => &szlig;

   [à] => &agrave;

   [á] => &aacute;

   [â] => &acirc;

   [ã] => &atilde;

   [ä] => &auml;

   [å] => &aring;

   [æ] => &aelig;

   [ç] => &ccedil;

   [è] => &egrave;

   [é] => &eacute;

   [ê] => &ecirc;

   [ë] => &euml;

   [ì] => &igrave;

   [í] => &iacute;

   [î] => &icirc;

   [ï] => &iuml;

   [ð] => &eth;

   [ñ] => &ntilde;

   [ò] => &ograve;

   [ó] => &oacute;

   [ô] => &ocirc;

   [õ] => &otilde;

   [ö] => &ouml;

   [÷] => &divide;

   [ø] => &oslash;

   [ù] => &ugrave;

   [ú] => &uacute;

   [û] => &ucirc;

   [ü] => &uuml;

   [ý] => &yacute;

   [þ] => &thorn;

   [ÿ] => &yuml;

   [Œ] => &OElig;

   [œ] => &oelig;

   [Š] => &Scaron;

   [š] => &scaron;

   [Ÿ] => &Yuml;

   [ƒ] => &fnof;

   [ˆ] => &circ;

   [˜] => &tilde;

   [Α] => &Alpha;

   [Β] => &Beta;

   [Γ] => &Gamma;

   [Δ] => &Delta;

   [Ε] => &Epsilon;

   [Ζ] => &Zeta;

   [Η] => &Eta;

   [Θ] => &Theta;

   [Ι] => &Iota;

   [Κ] => &Kappa;

   [Λ] => &Lambda;

   [Μ] => &Mu;

   [Ν] => &Nu;

   [Ξ] => &Xi;

   [Ο] => &Omicron;

   [Π] => &Pi;

   [Ρ] => &Rho;

   [Σ] => &Sigma;

   [Τ] => &Tau;

   [Υ] => &Upsilon;

   [Φ] => &Phi;

   [Χ] => &Chi;

   [Ψ] => &Psi;

   [Ω] => &Omega;

   [α] => &alpha;

   [β] => &beta;

   [γ] => &gamma;

   [δ] => &delta;

   [ε] => &epsilon;

   [ζ] => &zeta;

   [η] => &eta;

   [θ] => &theta;

   [ι] => &iota;

   [κ] => &kappa;

   [λ] => &lambda;

   [μ] => &mu;

   [ν] => &nu;

   [ξ] => &xi;

   [ο] => &omicron;

   [π] => &pi;

   [ρ] => &rho;

   [ς] => &sigmaf;

   [σ] => &sigma;

   [τ] => &tau;

   [υ] => &upsilon;

   [φ] => &phi;

   [χ] => &chi;

   [ψ] => &psi;

   [ω] => &omega;

   [ϑ] => &thetasym;

   [ϒ] => &upsih;

   [ϖ] => &piv;

   [ ] => &ensp;

   [ ] => &emsp;

   [ ] => &thinsp;

   [‌] => &zwnj;

   [‍] => &zwj;

   [‎] => &lrm;

   [‏] => &rlm;

   [–] => &ndash;

   [—] => &mdash;

   [‘] => &lsquo;

   [’] => &rsquo;

   [‚] => &sbquo;

   [“] => &ldquo;

   [”] => &rdquo;

   [„] => &bdquo;

   [†] => &dagger;

   [‡] => &Dagger;

   [•] => &bull;

   […] => &hellip;

   [‰] => &permil;

   [′] => &prime;

   [″] => &Prime;

   [‹] => &lsaquo;

   [›] => &rsaquo;

   [‾] => &oline;

   [⁄] => &frasl;

   [€] => &euro;

   [ℑ] => &image;

   [℘] => &weierp;

   [ℜ] => &real;

   [™] => &trade;

   [ℵ] => &alefsym;

   [←] => &larr;

   [↑] => &uarr;

   [→] => &rarr;

   [↓] => &darr;

   [↔] => &harr;

   [↵] => &crarr;

   [⇐] => &lArr;

   [⇑] => &uArr;

   [⇒] => &rArr;

   [⇓] => &dArr;

   [⇔] => &hArr;

   [∀] => &forall;

   [∂] => &part;

   [∃] => &exist;

   [∅] => &empty;

   [∇] => &nabla;

   [∈] => &isin;

   [∉] => &notin;

   [∋] => &ni;

   [∏] => &prod;

   [∑] => &sum;

   [−] => &minus;

   [∗] => &lowast;

   [√] => &radic;

   [∝] => &prop;

   [∞] => &infin;

   [∠] => &ang;

   [∧] => &and;

   [∨] => &or;

   [∩] => &cap;

   [∪] => &cup;

   [∫] => &int;

   [∴] => &there4;

   [∼] => &sim;

   [≅] => &cong;

   [≈] => &asymp;

   [≠] => &ne;

   [≡] => &equiv;

   [≤] => &le;

   [≥] => &ge;

   [⊂] => &sub;

   [⊃] => &sup;

   [⊄] => &nsub;

   [⊆] => &sube;

   [⊇] => &supe;

   [⊕] => &oplus;

   [⊗] => &otimes;

   [⊥] => &perp;

   [⋅] => &sdot;

   [⌈] => &lceil;

   [⌉] => &rceil;

   [⌊] => &lfloor;

   [⌋] => &rfloor;

   [〈] => &lang;

   [〉] => &rang;

   [◊] => &loz;

   [♠] => &spades;

   [♣] => &clubs;

   [♥] => &hearts;

   [♦] => &diams;

 )



❮PHP字符串参考