PHP get_html_translation_table() Function

PHP html_entity_decode() Function
PHP htmlentities() Function

In this article, you will learn how to get the translation table used by the PHP htmlentities() and htmlspecialchars() functions. The PHP GET_HTML_TRANSLATION_TABLE() function returns the translation table used by these two functions.

There exist some characters, which can be encoded in many ways, but the get_html_translation() function keep the common encoding method in the output.

What is the syntax of the GET_HTML_TRANSLATION_TABLE() function?

get_html_translation_table(function,flags,character-set)
ParameterDescription
functionOptional. Specifies which translation table to return.Possible values:HTML_SPECIALCHARS – Default. Translates some characters that need URL-encoding to be shown properly on a HTML pageHTML_ENTITIES – Translates all characters that need URL-encoding to be shown properly on a HTML page
flagsOptional. Specifies which quotes the table will contain and which document type the table is for.The available quote styles are:ENT_COMPAT – Default. Table contains entities for double quotes, not single quotesENT_QUOTES – Table contains entities for double and single quotesENT_NOQUOTES – Table will not contain entities for double and single quotesAdditional flags for specifying which doctype the table is for:ENT_HTML401 – Default. Table for HTML 4.01ENT_HTML5 – Table for HTML 5ENT_XML1 – Table for XML 1ENT_XHTML – Table for XHTML
character-setOptional. A string that specifies which character-set to use.Allowed values are:UTF-8 – Default. ASCII compatible multi-byte 8-bit UnicodeISO-8859-1 – Western EuropeanISO-8859-15 – Western European (adds the Euro sign + French and Finnish letters missing in ISO-8859-1)cp866 – DOS-specific Cyrillic charsetcp1251 – Windows-specific Cyrillic charsetcp1252 – Windows specific charset for Western EuropeanKOI8-R – RussianBIG5 – Traditional Chinese, mainly used in TaiwanGB2312 – Simplified Chinese, national standard character setBIG5-HKSCS – Big5 with Hong Kong extensionsShift_JIS – JapaneseEUC-JP – JapaneseMacRoman – Character-set that was used by Mac OSNote: 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.
PHP GET_HTML_TRANSLATION_TABLE() method

examples of the GET_HTML_TRANSLATION_TABLE() function

Example 1. In this example, we print the translation table for the HTML_SPECIALCHARS.

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

Example 2. In this example, we print the translation table for the HTML_ENTITIES.

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

Output of the above example is given below.

Array
(
  ["] => "
  [&] => &
  [<] => <
  [>] => >
  [ ] =>  
  [¡] => ¡
  [¢] => ¢
  [£] => £
  [¤] => ¤
  [¥] => ¥
  [¦] => ¦
  [§] => §
  [¨] => ¨
  [©] => ©
  [ª] => ª
  [«] => «
  [¬] => ¬
  [�­] => ­
  [®] => ®
  [¯] => ¯
  [°] => °
  [±] => ±
  [²] => ²
  [³] => ³
  [´] => ´
  [µ] => µ
  [¶] => ¶
  [·] => ·
  [¸] => ¸
  [¹] => ¹
  [º] => º
  [»] => »
  [¼] => ¼
  [½] => ½
  [¾] => ¾
  [¿] => ¿
  [À] => À
  [Á] => Á
  [Â] => Â
  [Ã] => Ã
  [Ä] => Ä
  [Å] => Å
  [Æ] => Æ
  [Ç] => Ç
  [È] => È
  [É] => É
  [Ê] => Ê
  [Ë] => Ë
  [Ì] => Ì
  [Í] => Í
  [Î] => Î
  [Ï] => Ï
  [Ð] => Ð
  [Ñ] => Ñ
  [Ò] => Ò
  [Ó] => Ó
  [Ô] => Ô
  [Õ] => Õ
  [Ö] => Ö
  [×] => ×
  [Ø] => Ø
  [Ù] => Ù
  [Ú] => Ú
  [Û] => Û
  [Ü] => Ü
  [Ý] => Ý
  [Þ] => Þ
  [ß] => ß
  [à] => à
  [á] => á
  [â] => â
  [ã] => ã
  [ä] => ä
  [å] => å
  [æ] => æ
  [ç] => ç
  [è] => è
  [é] => é
  [ê] => ê
  [ë] => ë
  [ì] => ì
  [í] => í
  [î] => î
  [ï] => ï
  [ð] => ð
  [ñ] => ñ
  [ò] => ò
  [ó] => ó
  [ô] => ô
  [õ] => õ
  [ö] => ö
  [÷] => ÷
  [ø] => ø
  [ù] => ù
  [ú] => ú
  [û] => û
  [ü] => ü
  [ý] => ý
  [þ] => þ
  [ÿ] => ÿ
  [Œ] => Œ
  [œ] => œ
  [Š] => Š
  [š] => š
  [Ÿ] => Ÿ
  [ƒ] => ƒ
  [ˆ] => ˆ
  [˜] => ˜
  [Α] => Α
  [Β] => Β
  [Γ] => Γ
  [Δ] => Δ
  [Ε] => Ε
  [Ζ] => Ζ
  [Η] => Η
  [Θ] => Θ
  [Ι] => Ι
  [Κ] => Κ
  [Λ] => Λ
  [Μ] => Μ
  [Ν] => Ν
  [Ξ] => Ξ
  [Ο] => Ο
  [Π] => Π
  [Ρ] => Ρ
  [Σ] => Σ
  [Τ] => Τ
  [Υ] => Υ
  [Φ] => Φ
  [Χ] => Χ
  [Ψ] => Ψ
  [Ω] => Ω
  [α] => α
  [β] => β
  [γ] => γ
  [δ] => δ
  [ε] => ε
  [ζ] => ζ
  [η] => η
  [θ] => θ
  [ι] => ι
  [κ] => κ
  [λ] => λ
  [μ] => μ
  [ν] => ν
  [ξ] => ξ
  [ο] => ο
  [π] => π
  [ρ] => ρ
  [ς] => ς
  [σ] => σ
  [τ] => τ
  [υ] => υ
  [φ] => φ
  [χ] => χ
  [ψ] => ψ
  [ω] => ω
  [ϑ] => ϑ
  [ϒ] => ϒ
  [ϖ] => ϖ
  [ ] =>  
  [ ] =>  
  [ ] =>  
  [‌] => ‌
  [‍] => ‍
  [‎] => ‎
  [‏] => ‏
  [–] => –
  [—] => —
  [‘] => ‘
  [’] => ’
  [‚] => ‚
  [“] => “
  [”] => ”
  [„] => „
  [†] => †
  [‡] => ‡
  [•] => •
  […] => …
  [‰] => ‰
  [′] => ′
  [″] => ″
  [‹] => ‹
  [›] => ›
  [‾] => ‾
  [⁄] => ⁄
  [€] => €
  [ℑ] => ℑ
  [℘] => ℘
  [ℜ] => ℜ
  [™] => ™
  [ℵ] => ℵ
  [←] => ←
  [↑] => ↑
  [→] => →
  [↓] => ↓
  [↔] => ↔
  [↵] => ↵
  [⇐] => ⇐
  [⇑] => ⇑
  [⇒] => ⇒
  [⇓] => ⇓
  [⇔] => ⇔
  [∀] => ∀
  [∂] => ∂
  [∃] => ∃
  [∅] => ∅
  [∇] => ∇
  [∈] => ∈
  [∉] => ∉
  [∋] => ∋
  [∏] => ∏
  [∑] => ∑
  [−] => −
  [∗] => ∗
  [√] => √
  [∝] => ∝
  [∞] => ∞
  [∠] => ∠
  [∧] => ∧
  [∨] => ∨
  [∩] => ∩
  [∪] => ∪
  [∫] => ∫
  [∴] => ∴
  [∼] => ∼
  [≅] => ≅
  [≈] => ≈
  [≠] => ≠
  [≡] => ≡
  [≤] => ≤
  [≥] => ≥
  [⊂] => ⊂
  [⊃] => ⊃
  [⊄] => ⊄
  [⊆] => ⊆
  [⊇] => ⊇
  [⊕] => ⊕
  [⊗] => ⊗
  [⊥] => ⊥
  [⋅] => ⋅
  [⌈] => ⌈
  [⌉] => ⌉
  [⌊] => ⌊
  [⌋] => ⌋
  [〈] => ⟨
  [〉] => ⟩
  [◊] => ◊
  [♠] => ♠
  [♣] => ♣
  [♥] => ♥
  [♦] => ♦
)
PHP html_entity_decode() Function
PHP htmlentities() Function

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top