The get_html_translation_table() function in PHP is used to return the translation table used by the htmlentities() and htmlspecialchars() functions.
Syntax
1 2 3 |
get_html_translation_table ([ int $table = HTML_SPECIALCHARS [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = "UTF-8" ]]] ) |
Parameter
table (optional)- This parameter specifies which translation table to return. It either returns HTML_ENTITIES or HTML_SPECIALCHARS.
flags (optional)- This parameter specifies which quotes the table will contain and which document type the table is for. The available flag constants are as follows:
- ENT_COMPAT- Table contains entities only for double-quotes
- ENT_QUOTES- The Table contains entities for both double and single quotes
- ENT_NOQUOTES- Table contains entities neither for single quotes nor for double quotes.
- ENT_HTML401- Table specifically for HTML 4.01.
- ENT_XML1- Table for XML 1.
- ENT_XHTML- Table for XHTML.
- ENT_HTML5- Table for HTML 5.
Character-set (optional)- It represents a string that specifies which character-set to use. The following character set are supported:
- UTF-8 – Default. ASCII compatible multi-byte 8-bit Unicode
- ISO-8859-1 – Western European
- ISO-8859-15 – Western European (adds the Euro sign + French and Finnish letters missing in ISO-8859-1)
- cp866 – DOS-specific Cyrillic charset
- cp1251 – Windows-specific Cyrillic charset
- cp1252 – Windows specific charset for Western European
- KOI8-R – Russian
- BIG5 – Traditional Chinese, mainly used in Taiwan
- GB2312 – Simplified Chinese, national standard character set
- BIG5-HKSCS – Big5 with Hong Kong extensions
- Shift_JIS – Japanese
- EUC-JP – Japanese
- MacRoman – Character-set that was used by Mac OS
Return
This function returns the translation table as an array, with the original characters as keys and entities as values.
Example 1
1 2 3 4 5 |
<?php print_r (get_html_translation_table(HTML_ENTITIES)); ?> |
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
Array ( ["] => " [&] => & [<] => < [>] => > [ ] => [¡] => ¡ [¢] => ¢ [£] => £ [¤] => ¤ [¥] => ¥ [¦] => ¦ [§] => § [¨] => ¨ [©] => © [ª] => ª [«] => « [¬] => ¬ [] => [®] => ® [¯] => ¯ [°] => ° [±] => ± [²] => ² [³] => ³ [´] => ´ [µ] => µ [¶] => ¶ [·] => · [¸] => ¸ [¹] => ¹ [º] => º [»] => » [¼] => ¼ [½] => ½ [¾] => ¾ [¿] => ¿ [À] => À [Á] => Á [Â] =>  [Ã] => à [Ä] => Ä [Å] => Å [Æ] => Æ [Ç] => Ç [È] => È [É] => É [Ê] => Ê [Ë] => Ë [Ì] => Ì [Í] => Í [Î] => Î [Ï] => Ï [Ð] => Ð [Ñ] => Ñ [Ò] => Ò [Ó] => Ó [Ô] => Ô [Õ] => Õ [Ö] => Ö [×] => × [Ø] => Ø [Ù] => Ù [Ú] => Ú [Û] => Û [Ü] => Ü [Ý] => Ý [Þ] => Þ [ß] => ß [à] => à [á] => á [â] => â [ã] => ã [ä] => ä [å] => å [æ] => æ [ç] => ç [è] => è [é] => é [ê] => ê [ë] => ë [ì] => ì [í] => í [î] => î [ï] => ï [ð] => ð [ñ] => ñ [ò] => ò [ó] => ó [ô] => ô [õ] => õ [ö] => ö [÷] => ÷ [ø] => ø [ù] => ù [ú] => ú [û] => û [ü] => ü [ý] => ý [þ] => þ [ÿ] => ÿ [Œ] => Œ [œ] => œ [Š] => Š [š] => š [Ÿ] => Ÿ [ƒ] => ƒ [ˆ] => ˆ [˜] => ˜ [Α] => Α [Β] => Β [Γ] => Γ [Δ] => Δ [Ε] => Ε [Ζ] => Ζ [Η] => Η [Θ] => Θ [Ι] => Ι [Κ] => Κ [Τ] => Τ [Υ] => Υ [Φ] => Φ [Χ] => Χ [Ψ] => Ψ [Ω] => Ω [α] => α [β] => β [γ] => γ [δ] => δ [ε] => ε [ζ] => ζ [η] => η [θ] => θ [ι] => ι [κ] => κ [λ] => λ [μ] => μ [ν] => ν [ξ] => ξ [ο] => ο [π] => π [ρ] => ρ [ς] => ς [σ] => σ [τ] => τ [υ] => υ [φ] => φ [χ] => χ [ψ] => ψ [ω] => ω [ϑ] => ϑ [ϒ] => ϒ [ϖ] => ϖ [ ] => [ ] => [ ] => [] => [] => [] => [] => [–] => – [—] => — [‘] => ‘ [’] => ’ [‚] => ‚ [“] => “ [”] => ” [„] => „ [†] => † [‡] => ‡ [•] => • […] => … [‰] => ‰ [′] => ′ [″] => ″ [‹] => ‹ [›] => › [‾] => ‾ [⁄] => ⁄ [€] => € [ℑ] => ℑ [℘] => ℘ [ℜ] => ℜ [™] => ™ [ℵ] => ℵ [←] => ← [↑] => ↑ [→] => → [↓] => ↓ [↔] => ↔ [↵] => ↵ [⇐] => ⇐ [⇑] => ⇑ [⇒] => ⇒ [⇓] => ⇓ [⇔] => ⇔ [∀] => ∀ [∂] => ∂ [∃] => ∃ [∅] => ∅ [∇] => ∇ [∈] => ∈ [∉] => ∉ [∋] => ∋ [∏] => ∏ [∑] => ∑ [−] => − [∗] => ∗ [√] => √ [∝] => ∝ [∞] => ∞ [∠] => ∠ [∧] => ∧ [∨] => ∨ [∩] => ∩ [∪] => ∪ [∫] => ∫ [∴] => ∴ [∼] => ∼ [≅] => ≅ [≈] => ≈ [≠] => ≠ [≡] => ≡ [≤] => ≤ [≥] => ≥ [⊂] => ⊂ [⊃] => ⊃ [⊄] => ⊄ [⊆] => ⊆ [⊇] => ⊇ [⊕] => ⊕ [⊗] => ⊗ [⊥] => ⊥ [⋅] => ⋅ [⌈] => ⌈ [⌉] => ⌉ [⌊] => ⌊ |
Example 2
1 2 3 4 5 |
<?php print_r (get_html_translation_table(HTML_SPECIALCHARS)); ?> |
Output
1 2 3 4 5 6 7 8 9 |
Array ( ["] => " [&] => & [<] => < [>] => > ) |
Example 3
1 2 3 4 5 |
<?php print_r (get_html_translation_table()); // The HTML_SPECIALCHARS is default. ?> |
Output
1 2 3 4 5 6 7 8 9 |
Array ( ["] => " [&] => & [<] => < [>] => > ) |