Example
Output the translation table used by the htmlspecialchars function:
Definition and Usage
The get_html_translation_table() function returns the translation table used by htmlentities() and htmlspecialchars().
Tip: Some characters can be encoded in 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 translation table will contain and which document type the translation table is for. Available quote types:
|
| character-set | Optional. A string specifying the character set to use. Allowed values:
|
Technical Details
| Return Value: | Returns the translation table as an array, with the original characters as keys and the entities as values. |
|---|---|
| PHP Version: | 4+ |
| Changelog: |
In PHP 5, the default value for the character-set parameter changed to UTF-8. In PHP 5.4, additional flags were added to specify the document type for which the translation table is applicable: ENT_HTML401, ENT_HTML5, ENT_XML1 and ENT_XHTML. In PHP 5.3.4, the character-set parameter was added. |
More Examples
Example 1
Translation table for HTML_SPECIALCHARS:
Displaying character and entity name:
Array ( =>" [&] =>& [<] =>< [>] =>> )
Example 2
Translation table for HTML_ENTITIES:
Displaying characters and their corresponding entity names:
Array ( =>" [&] =>& [< [>] =>> => [ยก] =>¡ [ยข] =>¢ [ยฃ] =>£ [ยค] =>¤ [ยฅ] =>¥ [ยฆ] =>¦ [ยง] =>§ [ยจ] =>¨ [ยฉ] =>© =>ª [ยซ] =>« [ยฌ] =>¬ [ยญ] =>­ [ยฎ] =>® [ยฏ] =>¯ [ยฐ] =>° [ยฑ] =>± =>² =>³ [ยด] =>´ =>µ [ยถ] =>¶ [ยท] =>· [ยธ] =>¸ =>¹ =>º [ยป] =>» =>¼ =>½ =>¾ [ยฟ] =>¿ =>À =>Á => =>à =>Ä =>Å =>Æ =>Ç =>È =>É =>Ê =>Ë =>Ì =>Í =>Î =>Ï =>Ð =>Ñ =>Ò =>Ó =>Ô =>Õ =>Ö [ร] =>× =>Ø =>Ù =>Ú =>Û =>Ü =>Ý =>Þ =>ß =>à =>á =>â =>ã =>ä =>å =>æ =>ç =>è =>é =>ê =>ë =>ì =>í =>î =>ï =>ð =>ñ =>ò =>ó =>ô =>õ =>ö [รท] =>÷ =>ø =>ù =>ú =>û =>ü =>ý =>þ =>ÿ =>Œ =>œ =>Š =>š =>Ÿ =>ƒ =>ˆ [ห] =>˜ =>Α =>Β =>Γ =>Δ =>Ε =>Ζ =>Η =>Θ =>Ι =>Κ =>Λ =>Μ =>Ν =>Ξ =>Ο =>Π =>Ρ =>Σ =>Τ =>Υ =>Φ =>Χ =>Ψ =>Ω =>α =>β =>γ =>δ =>ε =>ζ =>η =>θ =>ι =>κ =>λ =>μ =>ν =>ξ =>ο =>π =>ρ =>ς =>σ =>τ =>υ =>φ =>χ =>ψ =>ω =>ϑ =>ϒ =>ϖ =>  =>  =>  [โ] =>‌ [โ] =>‍ [โ] =>‎ [โ] =>‏ [โ] =>– [โ] =>— ['] =>‘ ['] =>’ [โ] =>‚ =>“ =>” [โ] =>„ [โ ] =>† [โก] =>‡ [โข] =>• [โฆ] =>… [โฐ] =>‰ [โฒ] =>′ [โณ] =>″ [โน] =>‹ [โบ] =>› [โพ] =>‾ [โ] =>⁄ [โฌ] =>€ =>ℑ [โ] =>℘ =>ℜ [โข] =>™ =>ℵ [โ] =>← [โ] =>↑ [โ] =>→ [โ] =>↓ [โ] =>↔ [โต] =>↵ [โ] =>⇐ [โ] =>⇑ [โ] =>⇒ [โ] =>⇓ [โ] =>⇔ [โ] =>∀ [โ] =>∂ [โ] =>∃ [โ ] =>∅ [โ] =>∇ [โ] =>∈ [โ] =>∉ [โ] =>∋ [โ] =>∏ [โ] =>∑ [โ] =>− [โ] =>∗ [โ] =>√ [โ] =>∝ [โ] =>∞ [โ ] =>∠ [โง] =>∧ [โจ] =>∨ [โฉ] =>∩ [โช] =>∪ [โซ] =>∫ [โด] =>∴ [โผ] =>∼ [โ ] =>≅ [โ] =>≈ )
YouTip