PHP get_html_translation_table() Function
Example
Print the translation table used by the htmlspecialchars function:
<?php
print_r (get_html_translation_table()); // HTML_SPECIALCHARS is default.
?>
Run example »
Definition and Usage
The get_html_translation_table() function returns the translation table used by the htmlentities() and htmlspecialchars() functions.
Tip: Some characters can be encoded several ways. The get_html_translation_table() function returns the most common encoding.
Syntax
get_html_translation_table(function,flags,character-set)
Parameter | Description |
---|---|
function | Optional. Specifies which translation table to return. Possible values:
|
flags | Optional. Specifies which quotes the table will contain and which document type the table is for.
The available quote styles are:
Additional flags for specifying which doctype the table is for:
|
character-set | Optional. A string that specifies which character-set to
use. Allowed values are:
Note: Unrecognized character-sets will be ignored and replaced by ISO-8859-1 in versions prior to PHP 5.4. As of PHP 5.4, it will be ignored an replaced by UTF-8. |
Technical Details
Return Value: | Returns the translation table as an array, with the original characters as keys and entities as values |
---|---|
PHP Version: | 4+ |
Changelog: | The default value for the character-set parameter was changed
to UTF-8 in PHP 5 The additional flags for specifying which doctype the table is for; ENT_HTML401, ENT_HTML5, ENT_XML1 and ENT_XHTML were added in PHP 5.4 The character-set parameter was added in PHP 5.3.4 |
More Examples
Example
Table for HTML_SPECIALCHARS:
<?php
print_r (get_html_translation_table(HTML_SPECIALCHARS));
?>
Displaying character and entity name:
Array
(
["] => "
[&] => &
[<] => <
[>] => >
)
Example 2
Table for HTML_ENTITIES:
<?php
print_r (get_html_translation_table(HTML_ENTITIES));
?>
Displaying character and entity name:
Array
(
["] => "
[&] => &
[<] => <
[>] => >
[ ] =>
[�] => ¡
[�] => ¢
[�] => £
[�] =>
¤
[�] => ¥
[�] => ¦
[�] => §
[�] => ¨
[�] => ©
[�] => ª
[�] => «
[�] => ¬
[�] =>
­
[�] => ®
[�] => ¯
[�] => °
[�] => ±
[�] => ²
[�] => ³
[�] => ´
[�] => µ
[�] =>
¶
[�] => ·
[�] => ¸
[�] => ¹
[�] => º
[�] => »
[�] => ¼
[�] => ½
[�] => ¾
[�] => ¿
[�] => À
[�] => Á
[�] => Â
[�] => Ã
[�] => Ä
[�] => Å
[�] => Æ
[�]
=> Ç
[�] => È
[�] => É
[�] => Ê
[�]
=> Ë
[�] => Ì
[�] => Í
[�] => Î
[�] =>
Ï
[�] => Ð
[�] => Ñ
[�] => Ò
[�] => Ó
[�] => Ô
[�] => Õ
[�] => Ö
[�] => ×
[�]
=> Ø
[�] => Ù
[�] => Ú
[�] => Û
[�]
=> Ü
[�] => Ý
[�] => Þ
[�] => ß
[�] => à
[�] => á
[�] => â
[�] => ã
[�] => ä
[�]
=> å
[�] => æ
[�] => ç
[�] => è
[�] =>
é
[�] => ê
[�] => ë
[�] => ì
[�] => í
[�] => î
[�] => ï
[�] => ð
[�] => ñ
[�] =>
ò
[�] => ó
[�] => ô
[�] => õ
[�] => ö
[�] => ÷
[�] => ø
[�] => ù
[�] => ú
[�] => û
[�] => ü
[�] => ý
[�] => þ
[�]
=> ÿ
[�] => Œ
[�] => œ
[�] => Š
[�] => š
[�] => Ÿ
[�] => ƒ
[�] => ˆ
[�] => ˜
[Α] =>
Α
[Β] => Β
[Γ] => Γ
[Δ] => Δ
[Ε] =>
Ε
[Ζ] => Ζ
[Η] => Η
[Θ] => Θ
[Ι] =>
Ι
[Κ] => Κ
[Λ] => Λ
[Μ] => Μ
[Ν] => Ν
[Ξ] => Ξ
[Ο] => Ο
[Π] => Π
[Ρ] => Ρ
[Σ] =>
Σ
[Τ] => Τ
[Υ] => Υ
[Φ] => Φ
[Χ] => Χ
[Ψ] => Ψ
[Ω] => Ω
[α] => α
[β] => β
[γ] =>
γ
[δ] => δ
[ε] => ε
[ζ] => ζ
[η] =>
η
[θ] => θ
[ι] => ι
[κ] => κ
[λ] =>
λ
[μ] => μ
[ν] => ν
[ξ] => ξ
[ο] => ο
[π] => π
[ρ] => ρ
[ς] => ς
[σ] => σ
[τ] =>
τ
[υ] => υ
[φ] => φ
[χ] => χ
[ψ] => ψ
[ω] => ω
[ϑ] => ϑ
[ϒ] => ϒ
[ϖ] => ϖ
[ ]
=>  
[ ] =>  
[ ] =>  
[] => ‌
[] => ‍
[] => ‎
[] => ‏
[�] => –
[�] => —
[�] => ‘
[�] => ’
[�] => ‚
[�] => “
[�] => ”
[�]
=> „
[�] => †
[�] => ‡
[�] => •
[�] =>
…
[�] => ‰
[′] => ′
[″] => ″
[�] => ‹
[�] => ›
[‾] => ‾
[⁄] => ⁄
[�] => €
[ℑ]
=> ℑ
[℘] => ℘
[ℜ] => ℜ
[�] => ™
[ℵ] => ℵ
[←] => ←
[↑] => ↑
[→] => →
[↓] => ↓
[↔] => ↔
[↵] => ↵
[⇐] => ⇐
[⇑] => ⇑
[⇒] => ⇒
[⇓] =>
⇓
[⇔] => ⇔
[∀] => ∀
[∂] => ∂
[∃] =>
∃
[∅] => ∅
[∇] => ∇
[∈] => ∈
[∉] => ∉
[∋] => ∋
[∏] => ∏
[∑] => ∑
[−] => −
[∗] => ∗
[√] => √
[∝] => ∝
[∞] => ∞
[∠] => ∠
[∧] =>
∧
[∨] => ∨
[∩] => ∩
[∪] => ∪
[∫] => ∫
[∴]
=> ∴
[∼] => ∼
[≅] => ≅
[≈] => ≈
[≠] =>
≠
[≡] => ≡
[≤] => ≤
[≥] => ≥
[⊂] => ⊂
[⊃]
=> ⊃
[⊄] => ⊄
[⊆] => ⊆
[⊇] => ⊇
[⊕] => ⊕
[⊗] => ⊗
[⊥] => ⊥
[⋅] => ⋅
[⌈] => ⌈
[⌉]
=> ⌉
[⌊] => ⌊
[⌋] => ⌋
[〈] => ⟨
[〉] =>
⟩
[◊] => ◊
[♠] => ♠
[♣] => ♣
[♥] =>
♥
[♦] => ♦
)
PHP String Reference