The translations performed are:‘&’ (ampersand) becomes ‘&’‘”‘ (double quote) becomes ‘”‘ when ENT_NOQUOTES is not set.”’ (single quote) becomes ”’ only when ENT_QUOTES is set.‘<’ (less than) becomes ‘<’‘>’ (greater than) becomes ‘>’ 功能差不多 但是htmlspecialchars只处理上面这几个html代码,而htmlentities却会转化所有的html代码.所以有的无法识别的中文它会把它转换成一堆乱码.看你自己的情况选用吧,建议是使用 htmlspecialchars
我的代码htmlentities($content, ENT_QUOTES,UTF-8);为什么$content里的汉字是乱码显示的错误提示是:charset `-8' not supported, assuming iso-8859-1 这是怎么回事
我改用了htmlspecialchars直接使用htmlspecialchars($content);就没有出现乱码htmlspecialchars函数与htmlentities有什么不同
The translations performed are:‘&’ (ampersand) becomes ‘&’‘”‘ (double quote) becomes ‘”‘ when ENT_NOQUOTES is not set.”’ (single quote) becomes ”’ only when ENT_QUOTES is set.‘<’ (less than) becomes ‘<’‘>’ (greater than) becomes ‘>’
功能差不多 但是htmlspecialchars只处理上面这几个html代码,而htmlentities却会转化所有的html代码.所以有的无法识别的中文它会把它转换成一堆乱码.看你自己的情况选用吧,建议是使用 htmlspecialchars