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 array_merge_recursive() Function

PHP array_merge_recursive() Function The array_merge_recursive() function  in PHP merges the elements of one or arrays together and returns the resulting array. Syntax array_merge_recursive (array $array  , [ array $... ] ) Parameter array(required)- This parameter specifies the input array ….(optional)- It represents more arrays to...

1 minute read.

PHP strcspn() Function

PHP strcspn() Function The strcspn() function in PHP returns the number of characters (including whitespaces) found in a string before any part of the specified characters is found. It is a binary-safe function. Syntax strcspn ( string $subject , string $mask [, int $start [, int $length ]] ) Parameter subject(required)- This...

1 minute read.

PHP array_push() Function

PHP array_push() Function The array_push() function in PHP pushes one or more elements onto the end of the array. This function increases the length of the array by the number of variables pushed. Syntax array_push ( array &$array, mixed& value [, mixed $... ]...

1 minute read.

PHP array_fill() function

PHP array_fill() function The array_fill() function in PHP fills an user-defined array with num entries of the value that of specified values parameter, where the keys start at the start_index parameter. Syntax array_fill ( int $start_index , int $num , mixed $value ) Parameter start_index(required)- This parameter represents the first index of the...

1 minute read.

PHP quoted_printable_decode() Function

PHP quoted_printable_decode() Function The quote_printable_decode() function of PHP converts a quoted-printable string to an 8 bit string. It works similar to imap_qprint(), except this one does not require the IMAP module to work. Syntax quoted_printable_decode ( string $str ) Parameter str(required)- This parameter represents the...

1 minute read.

PHP strtoupper() Function

The strtoupper() function in PHP is used to convert a string to uppercase. This function is binary-safe. The related functions are as follows: strtolower()lcfirst()ucfirst()ucwords() Syntax strtoupper ( string $string ) Parameter string(required)- This parameter represents the input string. Return This function returns a string with all alphabetic...

1 minute read.

PHP pos() Function

PHP pos() Function The pos() function in PHP returns the current element in an array which is initialized to the first element of the array. This function is an alias of current(). Syntax pos ( array...

1 minute read.

PHP Explode() Function

PHP Explode The PHP explode( ) is used to break a string into an array. The PHP explode( ) allow us to break a string into a smaller text with each break...

1 minute read.

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...

2 minutes read.

PHP natsort() Function

PHP natsort() Function The natsort() function in PHP Sort an array using a case insensitive "natural order" algorithm while maintaining the keys. Syntax natsort ( array &$array ) Parameter array(required)- This parameter represents the input array. Return This parameter returns a Boolean value TRUE on success or FALSE on...

1 minute 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 strstr() Function

PHP strstr() Function The strstr() function in PHP finds the first occurrence of a string. It returns part of the parameter haystack string starting from and including the first occurrence of needle to the end of the haystack parameter. This function is case-sensitive.  Syntax strstr ( string $haystack , mixed $needle [, bool $before_needle] )  Parameter  haystack(required)-...

2 minutes read.

PHP Date and Time

DATE: The PHP date() function formats a date or time. The timestamp is used to format a more readable date and time into a PHP date () function. Syntax: date(format,timestamp) Simple Date: Characters that...

1 minute read.

Composer Installation

Composer is an application-level package manager for the PHP Programming language. The development began in April 2011 and it was first released on March 1, 2012. Commands: require install update remove Installation:  Download the installer by visiting...

1 minute read.

PHP array_key_first() function

The array_key_first () function in PHP gets the first key of an array if the specified array is not empty. Syntax array_key_first(array;$array) Parameter array(required)- This parameter signifies the input array. Return This function returns the first key of the specified...

1 minute read.

PHP sizeof() Function

PHP sizeof() Function The sizeof() function in counts all elements and return the size of the array. This function is an alias of count(). Syntax sizeof( mixed $array_or_countable [, int $mode = COUNT_NORMAL ] )  Parameter array_or_countable(required)– This parameter represents the input array or countable object. mode(optional)-...

1 minute read.

PHP For Loops

PHP for loop is used when the specified condition is predefined. Syntax: for (initialization; condition; increment/decrement ) { code to be executed; } Example <!DOCTYPE html> <html> <head> <title>PHP Tutorial</title> </head> <body> <?php echo " Print counting using for loop"."<br>"; for($i=1;$i<=5;$i++){ echo $i."<br>"; } ?> </body> </html> Output Print counting using...

1 minute read.

PHP is_null() Function

The is_null() function in PHP is used to  find whether the specified variable is a null or not. It returns a Boolean value true if the parameter var is null else it returns...

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 array_diff_uassoc() Function

PHP array_diff_uassoc() Function The array_diff_uassoc () Function in PHP is used to compare the keys and values of two (or more) arrays and returns the differences (an array containing the entries from the first array that...

1 minute read.