PHP get_html_translation_table() Function

Last Updated:

PHP get_html_translation_table()

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

Note: Special characters can be encoded in several ways. E.g. " can be encoded as ", " or &#x22. The get_html_translation_table() function returns the most common encoding.

Example

PHP Compiler
<?php print_r(get_html_translation_table()) ?>

Syntax

get_html_translation_table(table, flag, character-set)

Parameter Values

ValueTypeExplanation
table Optional Specifies the table to return.
Possible Values:
  • HTML_ENTITIES
  • HTML_SPECIALCHARS
Default value is HTML_ENTITIES.
flag Optional Specifies which quotes the table will contain as well as which document type the table is for.
Possible Values:
  • ENT_COMPAT - Table will contain entities for double-quotes, but not for single-quotes.
  • ENT_QUOTES - Table will contain entities for both double and single quotes.
  • ENT_NOQUOTES - Table will neither contain entities for single quotes nor for double quotes.
The Default value is ENT_COMPAT.
character-set Optional Specifies the character-set to use.
Possible Values:
  • ISO-8859-1 - Western European, Latin-1.
  • ISO-8859-5 - Little used cyrillic charset (Latin/Cyrillic).
  • ISO-8859-15 - Western European, Latin-9. Adds the Euro sign, French and Finnish letters missing in Latin-1 (ISO-8859-1).
  • UTF-8 - ASCII compatible multi-byte 8-bit Unicode.
  • 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, Traditional Chinese.
  • Shift_JIS - Japanese
  • EUC-JP - Japanese
  • MacRoman - Charset that was used by Mac OS.
The Default value is 'UTF-8' (PHP 5.4.0 and above).

Return Value

ValueExplanation
Array Returns the translation table.

More Examples

Example

PHP Compiler
<?php print_r(get_html_translation_table(HTML_ENTITIES, ENT_NOQUOTES, 'MacRoman')) ?>

Share this Page

Meet the Author