Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

PHP 教程

PHP 主页 PHP 简介 PHP 安装 PHP 语法 PHP 注释 PHP 变量 PHP Echo / Print PHP 数据类型 PHP 字符串 PHP 数字 PHP 类型转换 PHP 数学 PHP 常量 PHP 魔术常量 PHP 运算符 PHP If...Else...Elseif PHP Switch PHP 循环 PHP 函数 PHP 数组 PHP 超全局变量 PHP 正则表达式

PHP 表单

PHP 表单处理 PHP 表单验证 PHP 表单必填项 PHP 表单 URL/电子邮件 PHP 表单完成

PHP 高级

PHP 日期和时间 PHP Include PHP 文件处理 PHP 文件打开/读取 PHP 文件创建/写入 PHP 文件上传 PHP Cookies PHP Sessions PHP 过滤器 PHP 过滤器高级 PHP 回调函数 PHP JSON PHP 异常

PHP OOP

PHP 什么是 OOP PHP 类/对象 PHP 构造函数 PHP 析构函数 PHP 访问修饰符 PHP 继承 PHP 常量 PHP 抽象类 PHP 接口 PHP 特性 PHP 静态方法 PHP 静态属性 PHP 命名空间 PHP 可迭代对象

MySQL 数据库

MySQL 数据库 MySQL 连接 MySQL 创建数据库 MySQL 创建表 MySQL 插入数据 MySQL 获取最后插入的 ID MySQL 插入多条数据 MySQL 预处理语句 MySQL 选择数据 MySQL Where MySQL Order By MySQL 删除数据 MySQL 更新数据 MySQL 限制数据

PHP XML

PHP XML 解析器 PHP SimpleXML 解析器 PHP SimpleXML - 获取 PHP XML Expat PHP XML DOM

PHP - AJAX

AJAX 简介 AJAX PHP AJAX 数据库 AJAX XML AJAX 实时搜索 AJAX 投票

PHP 示例

PHP 示例 PHP 编译器 PHP 测验 PHP 练习 PHP 服务器 PHP 证书

PHP 参考

PHP 概述 PHP 数组 PHP 日历 PHP 日期 PHP 目录 PHP 错误 PHP 异常 PHP 文件系统 PHP 过滤器 PHP FTP PHP JSON PHP 关键字 PHP Libxml PHP 邮件 PHP 数学 PHP 杂项 PHP MySQLi PHP 网络 PHP 输出控制 PHP 正则表达式 PHP SimpleXML PHP 流 PHP 字符串 PHP 变量处理 PHP XML 解析器 PHP Zip PHP 时区

PHP get_html_translation_table() 函数

❮ PHP 字符串参考

示例

打印 htmlspecialchars 函数使用的翻译表

<?php
print_r (get_html_translation_table()); // HTML_SPECIALCHARS 是默认值。
?>
自己试试 »

定义和用法

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

提示: 一些字符可以以几种方式编码。get_html_translation_table() 函数返回最常见的编码。


语法

get_html_translation_table(function,flags,character-set)

参数值

参数 描述
function 可选。指定要返回的翻译表。

可能的值

  • HTML_SPECIALCHARS - 默认。将一些需要 URL 编码才能在 HTML 页面上正确显示的字符进行翻译
  • HTML_ENTITIES - 将所有需要 URL 编码才能在 HTML 页面上正确显示的字符进行转换
标志 可选。指定表格将包含哪些引号以及表格针对哪种文档类型。

可用的引号样式为

  • ENT_COMPAT - 默认。表格包含双引号的实体,不包含单引号的实体
  • ENT_QUOTES - 表格包含双引号和单引号的实体
  • ENT_NOQUOTES - 表格不包含双引号和单引号的实体

用于指定表格针对哪种文档类型的附加标志

  • ENT_HTML401 - 默认。针对 HTML 4.01 的表格
  • ENT_HTML5 - 针对 HTML 5 的表格
  • ENT_XML1 - 针对 XML 1 的表格
  • ENT_XHTML - 针对 XHTML 的表格
字符集 可选。一个字符串,指定要使用的字符集。

允许的值为

  • UTF-8 - 默认。ASCII 兼容的多字节 8 位 Unicode
  • ISO-8859-1 - 西欧
  • ISO-8859-15 - 西欧(添加了欧元符号 + ISO-8859-1 中缺少的法语和芬兰语字母)
  • cp866 - DOS 专用 Cyrillic 字符集
  • cp1251 - Windows 专用 Cyrillic 字符集
  • 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+
更改日志 在 PHP 5 中,character-set 参数的默认值更改为 UTF-8

用于指定表格针对哪种文档类型的附加标志;ENT_HTML401、ENT_HTML5、ENT_XML1 和 ENT_XHTML 是在 PHP 5.4 中添加的

character-set 参数是在 PHP 5.3.4 中添加的

更多示例

示例

针对 HTML_SPECIALCHARS 的表格

<?php
print_r (get_html_translation_table(HTML_SPECIALCHARS));
?>

显示字符和实体名称

数组
(
  ["] => &quot;
  [&] => &amp;
  [<] => &lt;
  [>] => &gt;
)

示例

针对 HTML_ENTITIES 的表格

<?php
print_r (get_html_translation_table(HTML_ENTITIES));
?>

显示字符和实体名称

数组
(
  ["] => &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 字符串参考
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.