PHP get_html_translation_table() 函數

Example

輸出 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 - Default. Translate characters that need URL encoding to display correctly on HTML pages
  • HTML_ENTITIES - Translate all characters that need URL encoding to display correctly on HTML pages
flags

Optional. Specifies which quotes the translation table will include and for which document type the translation table is used.

Mga magagamit na uri ng salita:

  • ENT_COMPAT - Default. Translation table includes double quote entities, does not include single quote entities.
  • ENT_QUOTES - Translation table includes double quote entities and single quote entities.
  • ENT_NOQUOTES - Translation table does not include double quote entities and single quote entities.

Dagdag na flags para sa pagtutukoy ng uri ng dokumento kung anong gamit ang pagsasalin:

  • ENT_HTML401 - Default. Translation table for HTML 4.01.
  • ENT_HTML5 - Translation table for HTML 5.
  • ENT_XML1 - Translation table for XML 1.
  • ENT_XHTML - Translation table for XHTML.
character-set

Optional. String value, that specifies the charset to be used.

Pinahahalagang halaga:

  • UTF-8 - Default. 8-bit Unicode that is ASCII compatible
  • ISO-8859-1 - Western European
  • ISO-8859-15 - Western European (includes euro symbol + French and Finnish letters missing in ISO-8859-1)
  • cp866 - DOS exclusive Cyrillic charset
  • cp1251 - Windows exclusive Cyrillic charset
  • cp1252 - Windows exclusive Western European charset
  • KOI8-R - Russian
  • BIG5 - Traditional Chinese, pangunahing ginagamit sa Taiwan
  • GB2312 - Han Chinese, national character set
  • BIG5-HKSCS - BIG5 na may ekspansyon ng Hong Kong
  • Shift_JIS - Hapones
  • EUC-JP - Hapones
  • MacRoman - ang charset na ginagamit ng Mac na sistema operasyon

Komento:Sa mga bersyon ng PHP bago ang 5.4, ang mga character na hindi ma-identify ay ibinibigay na hindi ma-identify at pinalitan ng ISO-8859-1. Mula sa PHP 5.4, ang mga character na hindi ma-identify ay ibinibigay na hindi ma-identify at pinalitan ng UTF-8.

Detalye ng teknolohiya

Halaga ng pagbabalik: Babalik bilang forma ng array ang pagsasalin, ang orihinal na character bilang pangalan ng key, at ang entity bilang halaga ng key.
Bersyon ng PHP: 4+

Tala ng pag-update:

Bersyon Paliwanag
PHP 5 character-set Ang default na halaga ng parameter ay binago sa UTF-8.
PHP 5.4

Dagdag na flags para sa pagtutukoy ng uri ng dokumento kung anong gamit ang pagsasalin.

  • ENT_HTML401
  • ENT_HTML5
  • ENT_XML1
  • ENT_XHTML
PHP 5.3.4 Added character-set Parameters.

More examples

Example

HTML_SPECIALCHARS translation table:

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

Display characters and entity names:

Array
(
  ["] => "
  [&] => &
  [<] => <
  [>] => >
)

Example 2

HTML_ENTITIES translation table:

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

Display characters and entity names:

Array
(
  ["] => "
  [&] => &
  [<] => <
  [>] => >
  [ ] =>  
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ¿
  [?] => ä
  [?] => å
  [?] => æ
  [?] => ç
  [?] => è
  [?] => é
  [?] => ê
  [?] => ë
  [?] => ì
  [?] => í
  [?] => î
  [?] => ï
  [?] => ð
  [?] => ñ
  [?] => ò
  [?] => ó
  [?] => ô
  [?] => õ
  [?] => ö
  [?] => ÷
  [?] => ø
  [?] => ù
  [?] => ú
  [?] => û
  [?] => ü
  [?] => ý
  [?] => þ
  [?] => ÿ
  [?] => Œ
  [?] => œ
  [?] => Š
  [?] => š
  [?] => Ÿ
  [?] => ƒ
  [?] => Â
  [?] => ˜
  [Α] => Α
  [Β] => Β
  [Γ] => Γ
  [Δ] => Δ
  [Ε] => Ε
  [Ζ] => Ζ
  [Η] => Η
  [Θ] => Θ
  [Ι] => Ι
  [Κ] => Κ
  [Λ] => Λ
  [Μ] => Μ
  [Ν] => Ν
  [Ξ] => Ξ
  [Ο] => Ο
  [Π] => Π
  [Ρ] => Ρ
  [Σ] => Σ
  [Τ] => Τ
  [Υ] => Υ
  [Φ] => Φ
  [Χ] => Χ
  [Ψ] => Ψ
  [Ω] => Ω
  [α] => α
  [β] => β
  [γ] => γ
  [δ] => δ
  [ε] => ε
  [ζ] => ζ
  [η] => η
  [θ] => θ
  [ι] => ι
  [κ] => κ
  [λ] => λ
  [μ] => μ
  [ν] => ν
  [ξ] => ξ
  [ο] => ο
  [π] => π
  [ρ] => ρ
  [?] => ς
  [σ] => σ
  [τ] => τ
  [υ] => υ
  [φ] => φ
  [χ] => χ
  [ψ] => ψ
  [ω] => ω
  [?] => ϑ
  [?] => ϒ
  [?] => ϖ
  [?] =>  
  [?] =>
  [?] =>  
  [?] => ‌
  [?] => ‍
  [?] => ‎
  [?] => ‏
  [?] => –
  [?] => —
  [?] => ‘
  [?] => ’
  [?] => ‚
  [?] => “
  [?] => ”
  [?] => „
  [?] => †
  [?] => ‡
  [?] => •
  [?] => …
  [?] => ‰
  [′] => ′
  [″] => ″
  [?] => ‹
  [?] => ›
  [ ̄] => ‾
  [?] => ⁄
  [?] => €
  [?] => ℑ
  [?] => ℘
  [?] => ℜ
  [?] => ™
  [?] => ℵ
  [←] => ←
  [↑] => ↑
  [→] => →
  [↓] => ↓
  [?] => ↔
  [?] => ↵
  [?] => ⇐
  [?] => ⇑
  [?] => ⇒
  [?] => ⇓
  [?] => ⇔
  [?] => ∀
  [?] => ∂
  [?] => ∃
  [?] => ∅
  [?] => ∇
  [∈] => ∈
  [?] => ∉
  [?] => ∋
  [∏] => ∏
  [∑] => ∑
  [?] => −
  [?] => ∗
  [√] => √
  [∝] => ∝
  [∞] => ∞
  [∠] => ∠
  [∧] => ∧
  [∨] => ∨
  [∩] => ∩
  [∪] => ∪
  [∫] => ∫
  [∴] => ∴
  [~] => ∼
  [?] => ≅
  [≈] => ≈
  [≠] => ≠
  [≡] => ≡
  [≤] => ≤
  [≥] => ≥
  [?] => ⊂
  [?] => ⊃
  [?] => ⊄
  [?] => ⊆
  [?] => ⊇
  [⊕] => ⊕
  [?] => ⊗
  [⊥] => ⊥
  [?] => ⋅
  [?] => ⌈
  [?] => ⌉
  [?] => ⌊
  [?] => ⌋
  [?] => ⟨
  [?] => ⟩
  [?] => ◊
  [?] => ♠
  [?] => ♣
  [?] => ♥
  [?] => ♦
)