2016-01-21 58 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