Why does the PHP function htmlentities(…) returns wrong results?

妖精的绣舞 提交于 2019-12-05 14:58:42

Before PHP 5.4.0, htmlentities() expects ISO-8859-1 data by default. It's interpreting your UTF-8 input as single-byte characters, which results in the funny results you get.

Specify the encoding specifically.

$html = htmlentities($str, ENT_COMPAT, "UTF-8");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!