Current Location: Home> Function Categories> get_html_translation_table

get_html_translation_table

Returns the conversion table after using htmlspecialchars() and htmlentities()
Name:get_html_translation_table
Category:String
Programming Language:php
One-line Description:Returns the translation table used by htmlspecialchars() and htmlentities().

Definition and usage

get_html_translation_table() function returns the translation table used by htmlentities() and htmlspecialchars() functions.

Tip: Some characters can be encoded in many ways. get_html_translation_table() function returns the most common encoding.

Example

Example 1

Output the translation table used by the htmlspecialchars function:

 <?php
print_r ( get_html_translation_table ( ) ) ; // HTML_SPECIALCHARS is the default
?>

Try it yourself

Example 2

HTML_SPECIALCHARS translation table:

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

Show character and entity names:

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

Example 3

HTML_ENTITIES translation table:

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

Show character and entity names:

 Array
(
  ["] => "
  [&] => &
  [<] => <
  [>] => >
  [ ] =>
    [?] => ?
  [?] => ¢
  [?] => £
  [?] => ¤
  [?] => ¥
  [?] => |
  [?] => §
  [?] => ¨
  [?] => ?
  [?] => a
  [?] => ?
  [?] => ?
  [?] => -
  [?] => ?
  [?] => ˉ
  [?] => °
  [?] => ±
  [?] => 2
  [?] => 3
  [?] => ′
  [?] => μ
  [?] => ?
  [?] => ·
  [?] => ?
  [?] => 1
  [?] => o
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => à
  [?] => á
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => è
  [?] => é
  [?] => ê
  [?] => ?
  [?] => ì
  [?] => í
  [?] => ?
  [?] => ?
  [?] => D
  [?] => ?
  [?] => ò
  [?] => ó
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ×
  [?] => ?
  [?] => ù
  [?] => ú
  [?] => ?
  [?] => ü
  [?] => Y
  [?] => T
  [?] => ?
  [?] => à
  [?] => á
  [?] => a
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => è
  [?] => é
  [?] => ê
  [?] => ?
  [?] => ì
  [?] => í
  [?] => ?
  [?] => ?
  [?] => e
  [?] => ?
  [?] => ò
  [?] => ó
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ÷
  [?] => ?
  [?] => ù
  [?] => ú
  [?] => ?
  [?] => ü
  [?] => y
  [?] => t
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?

  [?] => ?
  [?] => ?
  [?] => ?
  [Α] => Α
  [Β] => Β
  [Γ] => Γ
  [Δ] => Δ
  [Ε] => Ε
  [Ζ] => Ζ
  [Η] => Η
  [Θ] => Θ
  [Ι] => Ι
  [Κ] => Κ
  [Λ] => Λ
  [Μ] => Μ
  [Ν] => Ν
  [Ξ] => Ξ
  [Ο] => Ο
  [Π] => Π
  [Ρ] => Ρ
  [Σ] => Σ
  [Τ] => Τ
  [Υ] => Υ
  [Φ] => Φ
  [Χ] => Χ
  [Ψ] => Ψ
  [Ω] => Ω
  [α] => α
  [β] => β
  [γ] => γ
  [δ] => δ
  [ε] => ε
  [ζ] => ζ
  [η] => η
  [θ] => θ
  [ι] => ι
  [κ] => κ
  [λ] => λ
  [μ] => μ
  [ν] => ν
  [ξ] => ξ
  [ο] => ο
  [π] => π
  [ρ] => ρ
  [?] => ?
  [σ] => σ
  [τ] => τ
  [υ] => υ
  [φ] => φ
  [χ] => χ
  [ψ] => ψ
  [ω] => ω
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => –
  [?] => —
  [?] => '
  [?] => '
  [?] => ?
  [?] => “
  [?] => ”
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => …
  [?] => ‰
  [′] => ′
  [″] => ″
  [?] => ?
  [?] => ?
  [ ̄] =>  ̄
  [?] => ?
  [?] => €
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [←] => ←
  [↑] => ↑
  [→] => →
  [↓] => ↓
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [∈] => ∈
  [?] => ?
  [?] => ?
  [∏] => ∏
  [∑] => ∑
  [?] => ?
  [?] => ?
  [√] => √
  [∝] => ∝
  [∞] => ∞
  [∠] => ∠
  [∧] => ∧
  [∨] => ∨
  [∩] => ∩
  [∪] => ∪
  [∫] => ∫
  [∴] => ∴
  [~] => ~
  [?] => ?
  [≈] => ≈
  [≠] => ≠
  [≡] => ≡
  [≤] => ≤
  [≥] => ≥
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [⊕] => ⊕
  [?] => ?
  [⊥] => ⊥
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
  [?] => ?
)

grammar

 get_html_translation_table ( function , flags , character - set )
parameter describe
function

Optional. Specifies which translation table to return.

Possible values:

  • HTML_SPECIALCHARS - Default. Translate characters that require URL encoded to be displayed correctly on HTML pages
  • HTML_ENTITIES - Translate all URL-encoded characters to correctly display on HTML pages
flags

Optional. Specifies which quotation marks will be included in the translation table and which document type the translation table will be used for.

Available quote types:

  • ENT_COMPAT - Default. The translation table contains double quoted entities and does not contain single quoted entities.
  • ENT_QUOTES - The translation table contains double quoted entities and single quoted entities.
  • ENT_NOQUOTES - The translation table does not contain double quote entities and single quote entities.

Additional flags that specify the type of document that the translation table applies to:

  • ENT_HTML401 - Default. HTML 4.01 translation table.
  • ENT_HTML5 - HTML 5 translation table.
  • ENT_XML1 - The translation table for XML 1.
  • ENT_XHTML - A translation table for XHTML.
character-set

Optional. String value, specifying the set of characters to be used.

Allowed values:

  • UTF-8 - Default. ASCII compatible with multi-byte 8-bit Unicode
  • ISO-8859-1 - Western Europe
  • ISO-8859-15 - Western Europe (added to the Euro symbol + missing French and Finnish letters in 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 expansion
  • Shift_JIS - Japanese
  • EUC-JP - Japanese
  • MacRoman - Character set used by Mac operating system

Note: In versions prior to PHP 5.4, unrecognized character sets will be ignored and replaced by ISO-8859-1. Since PHP 5.4, unrecognized character sets will be ignored and replaced by UTF-8.

Similar Functions
Popular Articles