The get_html_translation_table() function in PHP is used to return the translation table used by the htmlentities() and htmlspecialchars() functions.



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


This function returns the translation table as an array, with the original characters as keys and entities as values.

Example 1


Example 2


Example 3


Pin It on Pinterest

Share This