How to use get html translation table in PHP
In this article I will explain how get_html_translation_table() function can be used in PHP.
get_html_translation_table() function in PHP
The get_html_translation_table() function is
used to return the translation table used by the htmlentities() function and
htmlspecialchars() function.
Syntax
get_html_translation_table(function,quotestyle) |
Parameter
- function
function is optional parameter. it's return translation table. Default value
of function is HTML_SPECIALCHARS. Possible values:
- HTML_ENTITIES - Translates all
characters that need URL-encoding to be shown properly on a HTML page.
- HTML_SPECIALCHARS - Translates some
characters that need URL-encoding to be shown properly on a HTML page.
- quotestyle quotestyle is optional
parameter. it's defines how to encode single and double quotes. Default
value of quotestyle is ENT_COMPAT. Possible values:
- ENT_COMPAT - it encodes double quotes,
not single quotes.
- ENT_QUOTES - it encodes double and
single quotes.
- ENT_NOQUOTES - it does not encode
single or double quotes.
Example
The following example show to how the
get_html_translation_table() function can be used in PHP.
<html>
<body>
<h3 style="color:
brown;">get_html_translation_table() function example in PHP</h3>
<?php
echo 'Translation
table <br>';
print_r (get_html_translation_table());
echo '<br>
HTML_ENTITIES translation table <br>';
print_r (get_html_translation_table(HTML_ENTITIES));
echo '<br>
HTML_SPECIALCHARS translation table <br>';
print_r (get_html_translation_table(HTML_SPECIALCHARS,ENT_QUOTES));
?>
</body>
</html> |
Output
You may also want to read these related articles
here
Ask Your
Question
Got a programming related question? You
may want to post your question here