get_html_translation_table()
实例
输出 htmlspecialchars 函数使用的翻译表:
<?php
print_r (get_html_translation_table()); // HTML_SPECIALCHARS is default.
?>
print_r (get_html_translation_table()); // HTML_SPECIALCHARS is default.
?>
定义和用法
get_html_translation_table() 函数返回 htmlentities() 和 htmlspecialchars() 函数使用的翻译表。
提示:一些字符可以按照若干种方式进行编码。get_html_translation_table() 函数返回最普通的编码。
语法
get_html_translation_table(function,flags,character-set)
参数 | 描述 |
---|---|
function |
可选。规定返回哪个翻译表。
可能的值:
|
flags |
可选。规定翻译表将包含哪种引号以及翻译表用于哪种文档类型。
可用的引号类型:
规定翻译表适用的文档类型的附加 flags:
|
character-set |
可选。一个规定了要使用的字符集的字符串。
允许的值:
注释:在 PHP 5.4 之前的版本,无法被识别的字符集将被忽略并由 ISO-8859-1 替代。自 PHP 5.4 起,无法被识别的字符集将被忽略并由 UTF-8 替代。 |
技术细节
返回值: | 以数组形式返回翻译表,原始字符作为键名,实体作为键值。 |
---|---|
PHP 版本: | 4+ |
更新日志: |
在 PHP 5 中,character-set 参数的默认值改为 UTF-8。 在 PHP 5.4 中,新增了用于规定翻译表适用的文档类型的附加 flags:ENT_HTML401、ENT_HTML5、ENT_XML1 和 ENT_XHTML。 在 PHP 5.3.4 中,新增了 character-set 参数。 |
更多实例
实例
HTML_SPECIALCHARS 的翻译表:
<?php
print_r (get_html_translation_table(HTML_SPECIALCHARS));
?>
print_r (get_html_translation_table(HTML_SPECIALCHARS));
?>
Displaying character and entity name:
Array
(
["] => "
[&] => &
[<] => <
[>] => >
)
(
["] => "
[&] => &
[<] => <
[>] => >
)
实例 2
HTML_ENTITIES 的翻译表:
<?php
print_r (get_html_translation_table(HTML_ENTITIES));
?>
print_r (get_html_translation_table(HTML_ENTITIES));
?>
显示字符及其对应的实体名称:
Array
(
["] => "
[&] => &
[<] => <
[>] => >
[ ] =>
[?] => ¡
[¢] => ¢
[£] => £
[¤] => ¤
[¥] => ¥
[|] => ¦
[§] => §
[¨] => ¨
[?] => ©
[a] => ª
[?] => «
[?] => ¬
[-] => ­
[?] => ®
[ˉ] => ¯
[°] => °
[±] => ±
[2] => ²
[3] => ³
[′] => ´
[μ] => µ
[?] => ¶
[·] => ·
[?] => ¸
[1] => ¹
[o] => º
[?] => »
[?] => ¼
[?] => ½
[?] => ¾
[?] => ¿
[à] => À
[á] => Á
[?] => Â
[?] => Ã
[?] => Ä
[?] => Å
[?] => Æ
[?] => Ç
[è] => È
[é] => É
[ê] => Ê
[?] => Ë
[ì] => Ì
[í] => Í
[?] => Î
[?] => Ï
[D] => Ð
[?] => Ñ
[ò] => Ò
[ó] => Ó
[?] => Ô
[?] => Õ
[?] => Ö
[×] => ×
[?] => Ø
[ù] => Ù
[ú] => Ú
[?] => Û
[ü] => Ü
[Y] => Ý
[T] => Þ
[?] => ß
[à] => à
[á] => á
[a] => â
[?] => ã
[?] => ä
[?] => å
[?] => æ
[?] => ç
[è] => è
[é] => é
[ê] => ê
[?] => ë
[ì] => ì
[í] => í
[?] => î
[?] => ï
[e] => ð
[?] => ñ
[ò] => ò
[ó] => ó
[?] => ô
[?] => õ
[?] => ö
[÷] => ÷
[?] => ø
[ù] => ù
[ú] => ú
[?] => û
[ü] => ü
[y] => ý
[t] => þ
[?] => ÿ
[?] => Œ
[?] => œ
[?] => Š
[?] => š
[?] => Ÿ
[?] => ƒ
[?] => ˆ
[?] => ˜
[Α] => Α
[Β] => Β
[Γ] => Γ
[Δ] => Δ
[Ε] => Ε
[Ζ] => Ζ
[Η] => Η
[Θ] => Θ
[Ι] => Ι
[Κ] => Κ
[Λ] => Λ
[Μ] => Μ
[Ν] => Ν
[Ξ] => Ξ
[Ο] => Ο
[Π] => Π
[Ρ] => Ρ
[Σ] => Σ
[Τ] => Τ
[Υ] => Υ
[Φ] => Φ
[Χ] => Χ
[Ψ] => Ψ
[Ω] => Ω
[α] => α
[β] => β
[γ] => γ
[δ] => δ
[ε] => ε
[ζ] => ζ
[η] => η
[θ] => θ
[ι] => ι
[κ] => κ
[λ] => λ
[μ] => μ
[ν] => ν
[ξ] => ξ
[ο] => ο
[π] => π
[ρ] => ρ
[?] => ς
[σ] => σ
[τ] => τ
[υ] => υ
[φ] => φ
[χ] => χ
[ψ] => ψ
[ω] => ω
[?] => ϑ
[?] => ϒ
[?] => ϖ
[?] =>  
[?] =>  
[?] =>  
[?] => ‌
[?] => ‍
[?] => ‎
[?] => ‏
[–] => –
[—] => —
[‘] => ‘
[‘] => ’
[?] => ‚
["] => “
["] => ”
[?] => „
[?] => †
[?] => ‡
[?] => •
[…] => …
[‰] => ‰
[′] => ′
[″] => ″
[?] => ‹
[?] => ›
[ ̄] => ‾
[?] => ⁄
[€] => €
[?] => ℑ
[?] => ℘
[?] => ℜ
[?] => ™
[?] => ℵ
[←] => ←
[↑] => ↑
[→] => →
[↓] => ↓
[?] => ↔
[?] => ↵
[?] => ⇐
[?] => ⇑
[?] => ⇒
[?] => ⇓
[?] => ⇔
[?] => ∀
[?] => ∂
[?] => ∃
[?] => ∅
[?] => ∇
[∈] => ∈
[?] => ∉
[?] => ∋
[∏] => ∏
[∑] => ∑
[?] => −
[?] => ∗
[√] => √
[∝] => ∝
[∞] => ∞
[∠] => ∠
[∧] => ∧
[∨] => ∨
[∩] => ∩
[∪] => ∪
[∫] => ∫
[∴] => ∴
[~] => ∼
[?] => ≅
[≈] => ≈
[≠] => ≠
[≡] => ≡
[≤] => ≤
[≥] => ≥
[?] => ⊂
[?] => ⊃
[?] => ⊄
[?] => ⊆
[?] => ⊇
[⊕] => ⊕
[?] => ⊗
[⊥] => ⊥
[?] => ⋅
[?] => ⌈
[?] => ⌉
[?] => ⌊
[?] => ⌋
[?] => ⟨
[?] => ⟩
[?] => ◊
[?] => ♠
[?] => ♣
[?] => ♥
[?] => ♦
)
(
["] => "
[&] => &
[<] => <
[>] => >
[ ] =>
[?] => ¡
[¢] => ¢
[£] => £
[¤] => ¤
[¥] => ¥
[|] => ¦
[§] => §
[¨] => ¨
[?] => ©
[a] => ª
[?] => «
[?] => ¬
[-] => ­
[?] => ®
[ˉ] => ¯
[°] => °
[±] => ±
[2] => ²
[3] => ³
[′] => ´
[μ] => µ
[?] => ¶
[·] => ·
[?] => ¸
[1] => ¹
[o] => º
[?] => »
[?] => ¼
[?] => ½
[?] => ¾
[?] => ¿
[à] => À
[á] => Á
[?] => Â
[?] => Ã
[?] => Ä
[?] => Å
[?] => Æ
[?] => Ç
[è] => È
[é] => É
[ê] => Ê
[?] => Ë
[ì] => Ì
[í] => Í
[?] => Î
[?] => Ï
[D] => Ð
[?] => Ñ
[ò] => Ò
[ó] => Ó
[?] => Ô
[?] => Õ
[?] => Ö
[×] => ×
[?] => Ø
[ù] => Ù
[ú] => Ú
[?] => Û
[ü] => Ü
[Y] => Ý
[T] => Þ
[?] => ß
[à] => à
[á] => á
[a] => â
[?] => ã
[?] => ä
[?] => å
[?] => æ
[?] => ç
[è] => è
[é] => é
[ê] => ê
[?] => ë
[ì] => ì
[í] => í
[?] => î
[?] => ï
[e] => ð
[?] => ñ
[ò] => ò
[ó] => ó
[?] => ô
[?] => õ
[?] => ö
[÷] => ÷
[?] => ø
[ù] => ù
[ú] => ú
[?] => û
[ü] => ü
[y] => ý
[t] => þ
[?] => ÿ
[?] => Œ
[?] => œ
[?] => Š
[?] => š
[?] => Ÿ
[?] => ƒ
[?] => ˆ
[?] => ˜
[Α] => Α
[Β] => Β
[Γ] => Γ
[Δ] => Δ
[Ε] => Ε
[Ζ] => Ζ
[Η] => Η
[Θ] => Θ
[Ι] => Ι
[Κ] => Κ
[Λ] => Λ
[Μ] => Μ
[Ν] => Ν
[Ξ] => Ξ
[Ο] => Ο
[Π] => Π
[Ρ] => Ρ
[Σ] => Σ
[Τ] => Τ
[Υ] => Υ
[Φ] => Φ
[Χ] => Χ
[Ψ] => Ψ
[Ω] => Ω
[α] => α
[β] => β
[γ] => γ
[δ] => δ
[ε] => ε
[ζ] => ζ
[η] => η
[θ] => θ
[ι] => ι
[κ] => κ
[λ] => λ
[μ] => μ
[ν] => ν
[ξ] => ξ
[ο] => ο
[π] => π
[ρ] => ρ
[?] => ς
[σ] => σ
[τ] => τ
[υ] => υ
[φ] => φ
[χ] => χ
[ψ] => ψ
[ω] => ω
[?] => ϑ
[?] => ϒ
[?] => ϖ
[?] =>  
[?] =>  
[?] =>  
[?] => ‌
[?] => ‍
[?] => ‎
[?] => ‏
[–] => –
[—] => —
[‘] => ‘
[‘] => ’
[?] => ‚
["] => “
["] => ”
[?] => „
[?] => †
[?] => ‡
[?] => •
[…] => …
[‰] => ‰
[′] => ′
[″] => ″
[?] => ‹
[?] => ›
[ ̄] => ‾
[?] => ⁄
[€] => €
[?] => ℑ
[?] => ℘
[?] => ℜ
[?] => ™
[?] => ℵ
[←] => ←
[↑] => ↑
[→] => →
[↓] => ↓
[?] => ↔
[?] => ↵
[?] => ⇐
[?] => ⇑
[?] => ⇒
[?] => ⇓
[?] => ⇔
[?] => ∀
[?] => ∂
[?] => ∃
[?] => ∅
[?] => ∇
[∈] => ∈
[?] => ∉
[?] => ∋
[∏] => ∏
[∑] => ∑
[?] => −
[?] => ∗
[√] => √
[∝] => ∝
[∞] => ∞
[∠] => ∠
[∧] => ∧
[∨] => ∨
[∩] => ∩
[∪] => ∪
[∫] => ∫
[∴] => ∴
[~] => ∼
[?] => ≅
[≈] => ≈
[≠] => ≠
[≡] => ≡
[≤] => ≤
[≥] => ≥
[?] => ⊂
[?] => ⊃
[?] => ⊄
[?] => ⊆
[?] => ⊇
[⊕] => ⊕
[?] => ⊗
[⊥] => ⊥
[?] => ⋅
[?] => ⌈
[?] => ⌉
[?] => ⌊
[?] => ⌋
[?] => ⟨
[?] => ⟩
[?] => ◊
[?] => ♠
[?] => ♣
[?] => ♥
[?] => ♦
)