Output the translation table used by the htmlspecialchars function:
<?phpprint_r (get_html_translation_table()); // HTML_SPECIALCHARS is default.?>The get_html_translation_table() function returns the translation table used by the htmlentities() and htmlspecialchars() functions.
Tip: Some characters can be encoded in several ways. The get_html_translation_table() function returns the most common encoding.
get_html_translation_table( function, flags, character-set )
parameter | describe |
---|---|
function | Optional. Specifies which translation table to return. Possible values: HTML_SPECIALCHARS - Default. Translate certain characters that require URL encoding so they display correctly on HTML pages. HTML_ENTITIES - Translates all characters that require URL encoding to display correctly on HTML pages. |
flags | Optional. Specifies what kind of quotes the translation table will contain and what document type the translation table is for. Available quote types: ENT_COMPAT - Default. The translation table contains double-quoted entities but not single-quoted entities. ENT_QUOTES - Translation table contains double quote entities and single quote entities. ENT_NOQUOTES - The translation table does not contain double-quote entities and single-quote entities. Additional flags specifying the document types to which the translation table applies: 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. A string specifying the character set to be used. Allowed values: UTF-8 - Default. ASCII compatible multi-byte 8-bit Unicode ISO-8859-1 - Western Europe ISO-8859-15 - Western Europe (added euro symbol + French and Finnish letters missing from ISO-8859-1) cp866 - DOS-specific Cyrillic character set cp1251 - Windows-specific Cyrillic character set cp1252 - Windows-specific Western European character set KOI8-R - Russian BIG5 - Traditional Chinese, mainly used in Taiwan GB2312 - Simplified Chinese, national standard character set BIG5-HKSCS - Big5 with Hong Kong extension Shift_JIS - Japanese EUC-JP - Japanese MacRoman - Character set used by the Mac operating system Note: In versions prior to PHP 5.4, unrecognized character sets were ignored and replaced by ISO-8859-1. As of PHP 5.4, unrecognized character sets are ignored and replaced by UTF-8. |
Return value: | Return the translation table in the form of an array, with original characters as key names and entities as key values. |
---|---|
PHP version: | 4+ |
Update log: | In PHP 5, the default value of the character-set parameter changed to UTF-8. In PHP 5.4, additional flags have been added to specify the document types that the translation table applies to: ENT_HTML401, ENT_HTML5, ENT_XML1, and ENT_XHTML. In PHP 5.3.4, the character-set parameter was added. |
Translation table for HTML_SPECIALCHARS:
<?phpprint_r (get_html_translation_table(HTML_SPECIALCHARS));?>Displaying character and entity name:
Array( ["] => " [&] => & [<] => < [>] => >)Translation table for HTML_ENTITIES:
<?phpprint_r (get_html_translation_table(HTML_ENTITIES));?>Display characters and their corresponding entity names:
Array( ["] => " [&] => & [<] => < [>] => > [ ] => [¡] => ¡ [¢] => ¢ [£] => £ [¤] => ¤ [¥] => ¥ [¦] => ¦ [§] => § [¨] => ¨ [©] => © [ª] => ª [«] => « [¬] => ¬ [] => ­ [®] => ® [¯] => ¯ [°] => ° [±] => ± [²] => ² [³] => ³ [´] => ´ [µ] => µ [¶] => ¶ [·] => · [¸] => ¸ [¹] => ¹ [º] => º [»] => » [¼] = > ¼ [½] => ½ [¾] => ¾ [¿ ] => ¿ [À] => À [Á] => Á [Â] =>  [Ã] => à [Ä] => Ä [Å] => Å [Æ] => Æ [Ç] => Ç [Æ] = > È [É] => É [Ê] => Ê [Ë] => Ë [Ì] => Ì [Í] => Í [Î] => Î [Ï] => Ï [Ð] => Ð [Ñ] => Ñ [Ò] => Ò [Ó] => Ó ; [Ô] => Ô [Õ] => Õ [Ö] => Ö [×] => × [Ø] => Ø [Ù] => Ù [Ú] => Ú [Û] => Û [Ü] => Ü [Ý] => Ý [Þ] => Þ ; [ß] => ß [à] => à [á] => á [â] => â [ã] => ã [ä] => ä [å] => å [æ] => æ [ç] => ç [è] => è [é] => é [ ê] => ê [ë] => ë [ì] => ì [í] => í [î] => î [ï] => ï [ð] => ð [ñ] => ñ [ò] => ò [ó] => ó [ô] => ô [õ] => õ [ö] = > ö [÷] => ÷ [ø] => ø [ù] => ù [ú] => ú [û] => û [ü] => ü [ý] => ý [] => þ [ÿ] => ÿ [Œ] => Œ [œ] => œ [Š] = > Š [š] => š [Ÿ] => Ÿ [ƒ] => ƒ [ˆ] => ˆ [˜] => ˜ [Α] => Α [Β] => Β [Γ] => Γ [Δ] => Δ [Ε] => Ε [Ζ] => Ζ [ Η] => Η [Θ] => Θ [Ι] => Ι [Κ] => Κ [Λ] => Λ [Μ] => Μ [Ν] => Ν [Ξ] => Ξ [Ο] => Ο [Π] => Π [Ρ] => Ρ [Σ] => &Sigma ; [Τ] => Τ [Υ] => Υ [Φ] => Φ [Χ] => Χ [Ψ] => Ψ [Ω] => Ω [α] => α [β] => β [γ] => γ [δ] => δ [ε] => ε [ζ] = > ζ [η] => η [θ] => θ [ι] => ι [κ] => κ [λ] => λ [μ] => μ [ν] => ν [ξ] => ξ [ο] => ο [π] => π [ρ] => ρ [ς] => ς [ σ] => σ [τ] => τ [υ] => υ [φ] => φ [χ] => χ [ψ] => ψ [ω] => ω [ϑ] => ϑ [ϒ] => ϒ [ϖ] => ϖ [ ] =>   [ ] =>   [ ] =>   [] = > ‌ [] => ‍ [] => ‎ [] => ‏ [–] => – [—] => — ['] => ‘ ['] => ’ [‚] => ‚ ["] => “ ["] => ” [„] => &bdquo ; [†] => † [‡] => ‡ [•] => • […] => … [‰] => ‰ [′] => ′ [″] => ″ [‹] => ‹ [›] => › [‾] => ‾ [⁄] => ⁄ [€] => € [ ℑ] => ℑ [℘] => ℘ [ℜ] => ℜ [™] => ™ [ℵ] => ℵ [←] => ← [↑] => ↑ [→] => → [↓] => ↓ [↔] => ↔ [↵] => ↵ [⇐] = > ⇐ [⇑] => ⇑ [⇒] => ⇒ [doi] => ⇓ [⇔] => ⇔ [∀] => ∀ [∂] => ∂ [∃] => ∃ [∅] => ∅ [∇] => ∇ [∈] => ∈ [ ∉] => ∉ [∋] => ∋ [∏] => ∏ [∑] => ∑ [−] => − [∗] => ∗ [√] => √ [∝] => ∝ [∞] => ∞ [∠] => ∠ [∧] => ∧ [∨] => &or ; [∩] => ∩ [∪] => ∪ [∫] => ∫ [∴] => ∴ [∼] => ∼ [≅] => ≅ [≈] => ≈ [≠] => ≠ [≡] => ≡ [≤] => ≤ [≥] => ≥ [⊂] => &sub ; [⊃] => ⊃ [⊄] => ⊄ [⊆] => ⊆ [⊇] => ⊇ [⊕] => ⊕ [⊗] => ⊗ [⊥] => ⊥ [⋅] => ⋅ [⌈] => ⌈ [⌉] => ⌉ [⌊] => ⌊ [ ⌋] => ⌋ [〈] => ⟨ [〉] => ⟩ [◊] => ◊ [♠] => ♠ [♣] => ♣ [♥] => ♥ [♦] => ♦)