我正在使用 DOMDocument 生成一个 XML,这个 XML 必须有一个图像标签。
不知何故,当我这样做时(简化)
$response = new DOMDocument();
$actions = $response->createElement('actions');
$response->appendChild($actions);
$imageElement = $response->createElement('image');
$actions->appendChild($imageElement);
$anotherNode = $response->createElement('nodexy');
$imageElement->appendChild($anotherNode);
结果是
<actions>
<img>
<node></node>
</actions>
如果我将“image”更改为“images”甚至“img”,它会起作用。当我从 PHP 5.3.10 切换到 5.3.8 时,它也能正常工作。
这是错误还是功能?我的猜测是 DOMDocuments 假设我想构建一个 HTML img 元素......我能以某种方式阻止这种情况吗?
最奇怪的是:我无法在同一服务器上的另一个脚本中重现该错误。但我没有抓住模式......
这是该类的完整pastebin,导致错误: http: //pastebin.com/KqidsssM