例
打印在用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字符串參考