Peter Krauss
Peter Krauss

Reputation: 13940

PHP extends DOMDocument not accepting $config array

This example (I need to extend DOMDocument) shows the problem: var_dump(config) returns NULL (!), but there is an initialization.

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");
    }
}

Upvotes: 2

Views: 58

Answers (1)

Ry-
Ry-

Reputation: 225064

$config is apparently used internally by DOMDocument, whose constructor itself initializes it to NULL.

Choose any other name.

Upvotes: 2

Related Questions