2016-01-21 69 views
0

使用我不能创建一个新的DOMDocument:无法创建DOM文档

$dom = new DOMDocument; 

输出就是空的。不是像DOMDocument Object()这样的空对象,而是完全空的。通常它应该像一个对象:

DOMDocument Object 
(
    [doctype] => 
    [implementation] => (object value omitted) 
    [documentElement] => 
    [actualEncoding] => 
    [encoding] => 
    [xmlEncoding] => 
    [standalone] => 1 
    [xmlStandalone] => 1 
    [version] => 1.0 
    [xmlVersion] => 1.0 
    [strictErrorChecking] => 1 
    [documentURI] => 
    [config] => 
    [formatOutput] => 
    [validateOnParse] => 
    [resolveExternals] => 
    [preserveWhiteSpace] => 1 
    [recover] => 
    [substituteEntities] => 
    [...] 
) 

我使用PHP版本5.6.7和phpinfo()说:

DOM/XML:启用 DOM/XML API版本:20031129 的libxml版本:2.9.2`

服务器/脚本中还有其他PHP代码,所以我可以说PHP运行正常。任何建议下一步应该找到原因?

回答

0

试试这个:

<?php 
    $dom = new DOMDocument(); 
    var_dump($dom); 
?> 

输出:

object(DOMDocument)#1 (34) { ["doctype"]=> NULL ["implementation"]=> string(22) "(object value omitted)" ["documentElement"]=> NULL ["actualEncoding"]=> NULL ["encoding"]=> NULL ["xmlEncoding"]=> NULL ["standalone"]=> bool(true) ["xmlStandalone"]=> bool(true) ["version"]=> string(3) "1.0" ["xmlVersion"]=> string(3) "1.0" ["strictErrorChecking"]=> bool(true) ["documentURI"]=> NULL ["config"]=> NULL ["formatOutput"]=> bool(false) ["validateOnParse"]=> bool(false) ["resolveExternals"]=> bool(false) ["preserveWhiteSpace"]=> bool(true) ["recover"]=> bool(false) ["substituteEntities"]=> bool(false) ["nodeName"]=> string(9) "#document" ["nodeValue"]=> NULL ["nodeType"]=> int(9) ["parentNode"]=> NULL ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["attributes"]=> NULL ["ownerDocument"]=> NULL ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(0) "" } 

参考:http://php.net/manual/en/class.domdocument.php

+0

不幸的是这并没有改变任何东西。 – user3280615

+0

你的预期是什么? – Vegeta