【问题标题】:PHP extends DOMDocument not accepting $config arrayPHP 扩展 DOMDocument 不接受 $config 数组
【发布时间】:2013-07-15 07:04:52
【问题描述】:

这个例子(我需要扩展DOMDocument)显示了问题:var_dump(config)返回NULL(!),但是有一个初始化。

class DOMxDocument extends DOMDocument {
    public $X = 22;
    public $config = array(
       'a' => false,
       'b' => true
    );

    public function __construct($newconfig=NULL) {
         print "X={$this->X}\nY:";
         var_dump($this->config); // NULL!!
         parent::__construct("1.0", "UTF-8");
    }
}

【问题讨论】:

  • Seems to work perfectly fine,即使在 PHP 5.2 上也是如此。
  • 抱歉,我编辑的是 DOMDocument 和 var name "config" 的问题...
  • 对不起,不好的问题...现在我发现,手册说这是 DOM 的 deprecated 属性,它是只读的,所以我不能使用这个保留名称.

标签: php class properties


【解决方案1】:

$config 显然在内部由DOMDocument 使用,其构造函数本身将其初始化为NULL

选择任何其他名称。

【讨论】:

  • 是的,$config2 是有效的,谢谢!但现在的问题是“它是在哪里记录的?”......嗯......我找到了一些东西:readonly public DOMConfiguration $config;PHP manual
猜你喜欢
  • 1970-01-01
  • 2013-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多