The server is running with PHP 5.2.17, and I am trying to run get_html_translation_table() with three arguments. Here is how I invoke the function:
$text = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, "UTF-8");
I am getting a warning message saying
get_html_translation_table expects at most 2 parameters, 3 given
(filename and line number).
Per PHP Documentation, the third argument is supported after PHP 5.3.4, but adding the third argument is the only way I can think of to encode the array returned in “UTF-8”. (It works despite the ugly warning message.)
I need get_html_translation_table() to create a function that encode all html special characters and spaces, and the following function just won’t work without the third argument.
/**
* Trying to encoding all html special characters, including nl2br()
* @param string $original
* @return string
*/
function ecode_html_sp_chars($original) {
$table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, "UTF-8");
$table[' '] = ' ';
$encoded = strtr($original, $table);
return nl2br($encoded);
}
Two options: change your php version or use the htmlentities function. In htmlentities the encoding parameter was added in 4.1.
Example: