PHP get_html_translation_table() function
Example
Output the translation table used by the htmlspecialchars function:
<?php print_r (get_html_translation_table()); // HTML_SPECIALCHARS is the default ?>
Definition and Usage
The get_html_translation_table() function returns htmlentities() and htmlspecialchars() Translation table used by the function.
Tip:Some characters can be encoded in multiple 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 translation table will include and the document type for which the translation table is used. Available quote types:
Additional flags for specifying the document types applicable to the translation table:
|
character-set |
Optional. String value, specifying the character set to be used. Allowed values:
Note:In versions of PHP prior to 5.4, unrecognized character sets are ignored and replaced by ISO-8859-1. Starting with PHP 5.4, unrecognized character sets are ignored and replaced by UTF-8. |
Technical details
Return value: | The translation table is returned in array form, with the original character as the key name and the entity as the key value. |
PHP version: | 4+ |
Update log:
Version | Description |
---|---|
PHP 5 | character-set The default value of the parameter has been changed to UTF-8. |
PHP 5.4 |
Additional flags have been added to specify the document types applicable to the translation table:
|
PHP 5.3.4 | Added in character-set Parameter. |
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 ( ["] => " [&] => & [<] => < [>] => > [ ] => [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ? [?] => ä [?] => å [?] => æ [?] => ç [?] => è [?] => é [?] => ê [?] => ë [?] => ì [?] => í [?] => î [?] => ï [?] => ð [?] => ñ [?] => ò [?] => ó [?] => ô [?] => õ [?] => ö [?] => ÷ [?] => ø [?] => ù [?] => ú [?] => û [?] => ü [?] => ý [?] => þ [?] => ÿ [?] => Œ [?] => œ [?] => Š [?] => š [?] => Ÿ [?] => ƒ [?] =>  [?] => ˜ [Α] => Α [Β] => Β [Γ] => Γ [Δ] => Δ [Ε] => Ε [Ζ] => Ζ [Η] => Η [Θ] => Θ [Ι] => Ι [Κ] => Κ [Λ] => Λ [Μ] => Μ [Ν] => Ν [Ξ] => Ξ [Ο] => Ο [Π] => Π [Ρ] => Ρ [Σ] => Σ [Τ] => Τ [Υ] => Υ [Φ] => Φ [Χ] => Χ [Ψ] => Ψ [Ω] => Ω [α] => α [β] => β [γ] => γ [δ] => δ [ε] => ε [ζ] => ζ [η] => η [θ] => θ [ι] => ι [κ] => κ [λ] => λ [μ] => μ [ν] => ν [ξ] => ξ [ο] => ο [π] => π [ρ] => ρ [?] => ς [σ] => σ [τ] => τ [υ] => υ [φ] => φ [χ] => χ [ψ] => ψ [ω] => ω [?] => ϑ [?] => ϒ [?] => ϖ [?] => [?] => [?] => [?] => [?] => [?] => [?] => [?] => – [?] => — [?] => ‘ [?] => ’ [?] => ‚ [?] => “ [?] => ” [?] => „ [?] => † [?] => ‡ [?] => • [?] => … [?] => ‰ [′] => ′ [″] => ″ [?] => ‹ [?] => › [ ̄] => ‾ [?] => ⁄ [?] => € [?] => ℑ [?] => ℘ [?] => ℜ [?] => ™ [?] => ℵ [←] => ← [↑] => ↑ [→] => → [↓] => ↓ [?] => ↔ [?] => ↵ [?] => ⇐ [?] => ⇑ [?] => ⇒ [?] => ⇓ [?] => ⇔ [?] => ∀ [?] => ∂ [?] => ∃ [?] => ∅ [?] => ∇ [∈] => ∈ [?] => ∉ [?] => ∋ [∏] => ∏ [∑] => ∑ [?] => − [?] => ∗ [√] => √ [∝] => ∝ [∞] => ∞ [∠] => ∠ [∧] => ∧ [∨] => ∨ [∩] => ∩ [∪] => ∪ [∫] => ∫ [∴] => ∴ [~] => ∼ [?] => ≅ [≈] => ≈ [≠] => ≠ [≡] => ≡ [≤] => ≤ [≥] => ≥ [?] => ⊂ [?] => ⊃ [?] => ⊄ [?] => ⊆ [?] => ⊇ [⊕] => ⊕ [?] => ⊗ [⊥] => ⊥ [?] => ⋅ [?] => ⌈ [?] => ⌉ [?] => ⌊ [?] => ⌋ [?] => 〈 [?] => 〉 [?] => ◊ [?] => ♠ [?] => ♣ [?] => ♥ [?] => ♦ )