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