当然,之前已经提出了这个问题并且已经找到了解决方案,所有这些解决方案迄今为止都没有用我想通过使用htmlentities或htmlspecialchars将TM符号和&符改为他们的html equivelents:
$TEST = "Kold Locker™ & other stuff"; echo "ORGINIAL: " . $TEST . "<BR/>"; echo "HTML: " . htmlentities($TEST,ENT_COMPAT,'UTF-8');
这显示:
ORGINIAL: Kold Locker™ & other stuff HTML:
我也用htmlspecialchars尝试了它,第二个参数改变了相同的结果.
我错过了其他人声称在其他解决方案中工作的内容?
更新:我尝试显示utf8_encode($TEST)并显示HTML:Kold Locker™&其他的东西
你的代码适合我: – ?
在manual page for htmlentities()
我们可以读到:
Return Values
Returns the encoded string.
If the input string contains an invalid code unit sequence within the
given encoding an empty string will be returned,unless either the
ENT_IGnorE or ENT_SUBSTITUTE flags are set.
我的猜测是输入数据没有正确编码为UTF-8,函数返回一个空字符串. (假设脚本没有崩溃,即该部分仍然运行后的代码.)