public setDoctype ( string $doctype = null ) : |
||
$doctype | string | |
return |
public function setDoctype($doctype = null)
{
if (null !== $doctype) {
$doctype = (int) $doctype;
if (array_key_exists($doctype, Dom::$doctypes)) {
$this->doctype = $doctype;
switch ($this->doctype) {
case Dom::ATOM:
$this->contentType = 'application/atom+xml';
break;
case Dom::RSS:
$this->contentType = 'application/rss+xml';
break;
case Dom::XML:
$this->contentType = 'application/xml';
break;
default:
$this->contentType = 'text/html';
}
}
} else {
$this->doctype = null;
}
return $this;
}
public function testSetAndGetDoctype() { $d = new Dom(Dom::XHTML11); $d->setDoctype(Dom::ATOM); $this->assertContains('<?xml version="1.0"', $d->getDoctype()); $d->setDoctype(Dom::RSS); $this->assertContains('<?xml version="1.0"', $d->getDoctype()); $d->setDoctype(Dom::XML); $this->assertContains('<?xml version="1.0"', $d->getDoctype()); }