字符编码-文档标记为UTF-16,但在实体PHP错误中包含UTF-8内容


character encoding - Document labelled UTF-16 but has UTF-8 content in Entity PHP error

我最近将我的站点从PHP5.2转移到PHP5.3。我有一个身份验证模块,它早些时候工作得很好,但现在给出了错误

Document labelled UTF-16 but has UTF-8 content in Entity

我试过用UTF-16替换所有出现的UTF-8,但没有帮助。这个错误的可能解决方案/原因是什么?

请参阅:

http://forums.devshed.com/php-development-5/document-labelled-utf-16-but-has-utf-8-content-694388.html

这个链接的解决方案只是替换XML代码中的编码信息:

$xml = $result->GetWeatherResult;
$xml = preg_replace('/(<'?xml[^?]+?)utf-16/i', '$1utf-8', $xml);  

不是一个很好的解决方案,但适用于OP。