PHP Htmlentities - Double Coding

What condition do we use to decide when to set double encoding is true or false? What php configuration variable can we use to solve it?

For a Russian character, it should use double encoded true, then it displays the character. But if double encoding is false, the string will be displayed as empty. What condition do we use to set the double coded value to true or false?

+3
source share
1 answer

You can change this with the 4th argument. Set it FALSEso as not to encode twice.

$str = 'Hot & Cold and On & Off';

var_dump(htmlentities($str, ENT_COMPAT, 'UTF-8', FALSE));

Output

string(31) "Hot & Cold and On & Off"

CodePad .

+4
source

Source: https://habr.com/ru/post/1793508/


All Articles