PHP String get_html_translation_table() Function

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

Syntax

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

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

Output

Array
 (
     ["] => "
     [&] => & 
     [<] => <
     [>] => >
     [ ] =>  
     [¡] => ¡ 
     [¢] => ¢
     [£] => £
     [¤] => ¤
     [¥] => ¥ 
     [¦] => ¦
     [§] => §
     [¨] => ¨
     [©] => © 
     [ª] => ª
     [«] => «
     [¬] => ¬
     [­] => ­
     [®] => ®
     [¯] => ¯
     [°] => ° 
     [±] => ±
     [²] => ²
     [³] => ³
     [´] => ´
     [µ] => µ 
     [¶] => ¶
     [·] => ·
     [¸] => ¸
     [¹] => ¹
     [º] => º 
     [»] => »
     [¼] => ¼
     [½] => ½
     [¾] => ¾
     [¿] => ¿ 
     [À] => À
     [Á] => Á
     [Â] => Â
     [Ã] => Ã
     [Ä] => Ä
     [Å] => Å
     [Æ] => Æ 
     [Ç] => Ç
     [È] => È
     [É] => É
     [Ê] => Ê
     [Ë] => Ë
     [Ì] => Ì 
     [Í] => Í
     [Î] => Î
     [Ï] => Ï
     [Ð] => Ð
     [Ñ] => Ñ
     [Ò] => Ò
     [Ó] => Ó 
     [Ô] => Ô
     [Õ] => Õ
     [Ö] => Ö
     [×] => ×
     [Ø] => Ø
     [Ù] => Ù
     [Ú] => Ú
     [Û] => Û 
     [Ü] => Ü
     [Ý] => Ý
     [Þ] => Þ
     [ß] => ß
     [à] => à
     [á] => á
     [â] => â 
     [ã] => ã
     [ä] => ä
     [å] => å
     [æ] => æ
     [ç] => ç
     [è] => è
     [é] => é
     [ê] => ê 
     [ë] => ë
     [ì] => ì
     [í] => í
     [î] => î
     [ï] => ï
     [ð] => ð
     [ñ] => ñ 
     [ò] => ò
     [ó] => ó
     [ô] => ô
     [õ] => õ
     [ö] => ö
     [÷] => ÷
     [ø] => ø
     [ù] => ù 
     [ú] => ú
     [û] => û
     [ü] => ü
     [ý] => ý
     [þ] => þ
     [ÿ] => ÿ
     [Œ] => Œ 
     [œ] => œ
     [Š] => Š
     [š] => š
     [Ÿ] => Ÿ
     [ƒ] => ƒ
     [ˆ] => ˆ
     [˜] => ˜
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [–] => –
     [—] => —
     [‘] => ‘ 
     [’] => ’
     [‚] => ‚
     [“] => “
     [”] => ”
     [„] => „
     [†] => †
     [‡] => ‡
     [•] => • 
     […] => …
     [‰] => ‰
     [?] => ?
     [?] => ?
     [‹] => ‹
     [›] => ›
     [?] => ?
     [?] => ?
     [€] => € 
     [?] => ?
     [?] => ?
     [?] => ?
     [™] => ™
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ?
     [?] => ? 
     [?] => √
     [?] => ∝
     [?] => ∞
     [?] => ∠
     [?] => ∧
     [?] => ∨
     [?] => ∩
     [?] => ∪
     [?] => ∫
     [?] => ∴
     [?] => ∼
     [?] => ≅
     [?] => ≈
     [?] => ≠
     [?] => ≡
     [?] => ≤
     [?] => ≥
     [?] => ⊂
     [?] => ⊃
     [?] => ⊄
     [?] => ⊆
     [?] => ⊇
     [?] => ⊕
     [?] => ⊗
     [?] => ⊥
     [?] => ⋅
     [?] => ⌈
     [?] => ⌉
     [?] => ⌊ 

Example 2

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

Output

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

Example 3

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

Output

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

Related Topics

PHP Switch Statement with Example

PHP switch statement The PHP switch statement is used to execute one condition from many conditions.It similar to if statements on the same expression. Syntax: switch(n) {             case1: statement if n=case1; break;             case2:             statement if n=case2; break;             case3:            ...

3 minutes read.

PHP array_multisort() Function

PHP array_multisort () Function The array_multisort() function in PHP sorts multiple or multi-dimensional arrays at once. Syntax array_multisort ( array &$array1 [, mixed $array1_sort_order [, mixed $array1_sort_flags [, mixed $... ]]] ) Parameter array1(required)- This parameter specified the input array to sort. array1_sort_order(optional)- This parameter specifies the order (ascending or descending)...

1 minute read.

PHP unset() Function

PHP unset() Function The unset() function in PHP is used to unset a given variable. This function destroys the specified variables. If this function is called inside any user-defined function, then it unsets the value associated with...

1 minute read.

PHP if..Else..Elseif

PHP conditional statements are used to test the conditions. It supports different types of conditional statement. Following are the types of conditional statement if statement ..else statement ..elseif....else statement switch statement PHP if Statement PHP...

2 minutes read.

PHP strripos() Function

PHP strripos() Function The strripos() function in PHP finds the position of the last occurrence of a substring in the specified string. It is a case-insensitive and binary-safe function. Syntax strripos ( string $haystack , mixed $needle [, int $offset ] ) Parameter haystack(required)- This parameter signifies the...

1 minute read.

PHP setlocale() Function

PHP setlocale() Function The setlocale() function in PHP sets locale information(language, monetary, time and, other information specific for a geographical area.) Syntax setlocale ( int $category , array $locale ) Parameter category(required)- This parameter specified a named constant specifying the category of the functions affected...

1 minute read.

PHP stristr() Function

PHP stristr() Function The stristr() function in PHP finds the first occurrence of a string and returns the matched substring. It is a case-insensitive function. Syntax stristr ( string $haystack , mixed $needle [, bool $before_needle ] ) Parameter haystack(required)- This parameter represents the input string. needle(required)- This parameter...

2 minutes read.

PHP chr() Function

PHP chr() Function The chr() function in PHP generates a single byte string from a number and returns a one-character string containing the character as specified by the unsigned integer. Syntax chr(bytevalue);    Parameter bytevalue(required)- This...

1 minute read.

PHP is_array() Function

The is_array() Function in PHP is used to  find whether a variable is an array or not. It returns a Boolean value true if the parameter var is an array else it returns...

1 minute read.

PHP strcmp() Function

PHP strcmp() Function The strcmp() function in PHP compares two strings. It is a binary-safe case-sensitive string function. This function is similar to the strncmp() function, with the difference that you can specify the number of characters from each...

1 minute read.

PHP Arrays

PHP Array is usedto hold more than one value at a time.  In another words, we can say that an array stores multiple values in one single variable. Following are the...

2 minutes read.

PHP Comment

PHP commentis a line of code that is not executed. It is often used by developer to understand the code. PHP support single and multiple comments. In other language like C,...

1 minute read.

PHP Do While Loop

PHP do while loop is used to execute the code at least one time because condition is checked after executing the code. Syntax: do{ //code to be executed  }while(condition); Output <?php $n=1;  do{ echo "$n<br/>";  $n++;  }while($n<=5);  ?> Output 1 2 3 4 5 ← Prev Next →...

1 minute read.

PHP reset() Function

PHP reset() Function The reset() function in PHP is used to set the internal pointer of an array to its first element and returns the value of the first array element. Syntax reset ( array &$array )  Parameter array(required)- This parameter represents...

1 minute read.

PHP substr_compare() Function

PHP substr_compare() Function The substr_compare() function in PHP compares two strings from a specified start position. It is a binary-safe and optionally case-sensitive function. Syntax substr_compare ( string $main_str , string $str , int $offset [, int $length [, bool$case_insensitivity]] )  Parameter main_str(required)- This parameter specifies the first string to compare. str(required)- This parameter...

1 minute read.

PHP addslashes() Function

PHP addslashes() Function The addslashed() function in PHP is used to return a string with backslashes in front of predefined characters. This function is only used with some characters which are...

1 minute read.

PHP array_fill_keys() Function

The array_fill_keys() function in PHP fills an array with the value of the specified value parameter, using the values of the specified keys array as keys. Syntax array_fill_keys ( array $keys , mixed $value ) Parameter keys(required)- This parameter signifies the input array of values that will be...

1 minute read.

PHP array_unique() Function

PHP array_unique() Function The array_unique() function in PHP removes the duplicate values from the specified array. Syntax array_unique (array $array [, int $sort_flags = SORT_STRING]) Parameter array(required)- This array represents the first input array. sort_flags (optional)- This parameter is used to modify the sorting behavior. The...

1 minute read.

PHP ucfirst() Function

PHP ucfirst() Function The ucfirst() function in PHP converts the first character of the specified string to uppercase. Syntax ucfirst ( string $str ) Parameter str(required)- This parameter represents the input string. Return This function returns a string with the first character of the specified string capitalized if that...

1 minute read.

PHP htmlspecialchars() Function

PHP htmlspecialchars() Function The htmlspecialchars() function in PHP converts some special predefined characters to HTML entities. The special predefined characters are as follows: & (ampersand) OR &amp;" (double quote) OR &quot;' (single quote) OR &#039;<...

2 minutes read.