w3resource

PHP: get_html_ translation_ table() function

Description

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

Version

(PHP 4 PHP 5 )

Syntax

get_html_translation_table(table, quote_style)

Parameters

Name Description Required /
Optional
Type
table For a given string, two constants either HTML_ENTITIES or HTML_SPECIALCHARS, defines what kind of character to html entities mapping is to be done. Optional Integer
quote_style Refers to a style of encoding single and double quote.
ENT_COMPAT : Only convert double quotes, leaving single quotes unaltered. This is the default one.
ENT_QUOTES : Converts both single and double quotes.
ENT_NOQUOTES: Converts neither single nor double quotes.
Optional Integer

Return values:

The translation table as an array.

Value Type: Array.

Pictorial Presentation

php-string-get_html_translation_table()

Example:

<?phpprint_r (get_html_translation_table());echo '<br>';print_r (get_html_translation_table(HTML_ENTITIES));echo '<br>';print_r (get_html_translation_table(HTML_SPECIALCHARS,ENT_QUOTES));?>

Output:

Array  (      ["] => "      [<] => <      [>] => >      [&] => &  ) 
Array ( [ ] =>   [¡] => ¡ [¢] => ¢ [£] => £ [¤] => ¤ [¥] => ¥ [¦] => ¦ [§] => § [¨] => ¨ [©] => © [ª] => ª [«] => « [¬] => ¬ [­] => ­ [®] => ® [¯] => ¯ [°] => ° [±] => ± [²] => ² [³] => ³ [´] => ´ [µ] => µ [¶] => ¶ [·] => · [¸] => ¸ [¹] => ¹ [º] => º [»] => » [¼] => ¼ [½] => ½ [¾] => ¾ [¿] => ¿ [À] => À [Á] => Á [Â] => Â [Ã] => Ã [Ä] => Ä [Å] => Å [Æ] => Æ [Ç] => Ç [È] => È [É] => É [Ê] => Ê [Ë] => Ë [Ì] => Ì [Í] => Í [Î] => Î [Ï] => Ï [Ð] => Ð [Ñ] => Ñ [Ò] => Ò [Ó] => Ó [Ô] => Ô [Õ] => Õ [Ö] => Ö [×] => × [Ø] => Ø [Ù] => Ù [Ú] => Ú [Û] => Û [Ü] => Ü [Ý] => Ý [Þ] => Þ [ß] => ß [à] => à [á] => á [â] => â [ã] => ã [ä] => ä [å] => å [æ] => æ [ç] => ç [è] => è [é] => é [ê] => ê [ë] => ë [ì] => ì [í] => í [î] => î [ï] => ï [ð] => ð [ñ] => ñ [ò] => ò [ó] => ó [ô] => ô [õ] => õ [ö] => ö [÷] => ÷ [ø] => ø [ù] => ù [ú] => ú [û] => û [ü] => ü [ý] => ý [þ] => þ [ÿ] => ÿ ["] => " [<] => < [>] => > [&] => & )
Array ( ["] => " ['] => ' [<] => < [>] => > [&] => & )

View the example in the browser

See also

PHP Function Reference

Previous: fprintf
Next: hebrev



PHP: Tips of the Day

PHP: How to write to the console in PHP?

Firefox

On Firefox you can use an extension called FirePHP which enables the logging and dumping of information from your PHP applications to the console. This is an addon to the awesome web development extension Firebug.

  • http://www.studytrails.com/blog/using-firephp-in-firefox-to-debug-php/

Chrome

However if you are using Chrome there is a PHP debugging tool called Chrome Logger or webug (webug has problems with the order of logs).

More recently Clockwork is in active development which extends the Developer Tools by adding a new panel to provide useful debugging and profiling information. It provides out of the box support for Laravel 4 and Slim 2 and support can be added via its extensible API.

Using Xdebug

A better way to debug your PHP would be via Xdebug. Most browsers provide helper extensions to help you pass the required cookie/query string to initialize the debugging process.

  • Chrome - Xdebug Helper
  • Firefox - The easiest Xdebug
  • Opera - Xdebug
  • Safari - Xdebug Toggler

Ref : https://bit.ly/3ck9rFg