首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法创建DOMdocument

无法创建DOMdocument
EN

Stack Overflow用户
提问于 2016-01-21 09:40:09
回答 1查看 451关注 0票数 0

我不能使用以下方法创建新的DOMdocument:

代码语言:javascript
复制
$dom = new DOMDocument;

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

代码语言:javascript
复制
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] => 
    [...]
)

我使用的是PHP5.6.7版本,phpinfo()说:

DOM/XML:启用DOM/XML版本: 20031129 libxml版本:2.9.2

服务器/脚本中还有其他PHP代码,所以我可以说PHP正常运行。有什么建议,接下来的步骤应该是找出原因吗?

EN

回答 1

Stack Overflow用户

发布于 2016-01-21 10:20:26

试试这个:

代码语言:javascript
复制
<?php
    $dom = new DOMDocument();
    var_dump($dom);
?>

产出:

代码语言:javascript
复制
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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34920055

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档