a.php
#!/usr/bin/php
<?php
class HtmlTable extends DOMElement
{
public function __construct($height, $width)
{
parent::__construct("table");
for ($i = 0; $i < $height; ++$i) {
$row = $this->appendChild(new DOMElement("tr"));
for($j = 0; $j < $width; ++$j) {
$row->appendChild(new DOMElement("td"));
}
}
}
}
$document = new DOMDocument("1.0", "UTF-8");
$document->registerNodeClass("DOMElement", "HtmlTable");
$document->appendChild(new HtmlTable(3, 2));
$document->saveXML();
O alır Koşu
Fatal error: Uncaught exception 'DOMException' with message 'No Modification Allowed Error' in /home/www/a.php:9
Stack trace:
#0 /home/www/a.php(9): DOMNode->appendChild(Object(DOMElement))
#1 /home/www/a.php(19): HtmlTable->__construct(3, 2)
#2 {main}
thrown in /home/www/a.php on line 9