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 .
source
share