我有一个使用XMLWriter
. 它在 PHP 5.6 vagrant box 上的 dev 中完美运行。在实时服务器上,运行 PHP 5.4 的提要无法呈现并显示一条消息:
This page contains the following errors:
error on line 3 at column 6: XML declaration allowed only at the start of the document
如果您查看源代码,它看起来像这样:
不知何故,有几行被添加到 XML 文档中。服务器之间的唯一区别是 PHP 版本(据我所知)。
下面是 XMLWriter 代码的前几行:
$xml = new XMLWriter();
$xml->openURI('php://output');
$xml->startDocument("1.0");
$xml->setIndent(true);
$xml->startElement("propertyList");
$xml->writeAttribute('date', date('Y-m-d-H:i:s'));
任何想法如何解决这个问题?