PHP » Strings » get_html_translation_table()

Syntax:
array get_html_translation_table(int table [, int quote_style])
table
Which table to return.
quote_style
How to escape quotes.

Returns a html translation table array.

The translation tables used by htmlspecialchars() and htmlentities() can be fetched with get_html_translation_table(). The table returned is in the form of an associative array. The table parameter can be set to one of the two values HTML_ENTITIES and HTML_SPECIALCHARS. The possible values for quote_style are ENT_COMPAT, which only escapes double quotes, ENT_NOQUOTES, for no quote escaping, and ENT_QUOTES for escaping both double and single quotes.

Examples

Code:
<pre>
<?php

print htmlspecialchars(print_r(get_html_translation_table(HTML_SPECIALCHARS), TRUE));

?>
</pre>
Output:
Array
(
   [&] => &amp;
   ["] => &quot;
   [<] => &lt;
   [>] => &gt;
)
Explanation:

This code prints the contents of the HTML_SPECIALCHARS table. The HTML_ENTITIES table is much larger.

See Also: