Forum Moderators: coopster
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
// from the php manual
$impl = new DOMImplementation();
$doctype = $impl->createDocumentType("html",
"-//W3C//DTD HTML 4.01//EN",
"http://www.w3.org/TR/html4/strict.dtd");
$document = $impl->createDocument(null, null, $doctype);
echo $document->saveXML();
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
//wooo hooo
$pubId = $doctype->publicId;
if($pubId == '-//W3C//DTD HTML 4.01//EN' )
include_once("navphphtml401strict.inc");
<!DOCTYPE... of the current document. I'm not the DOMImplementation expert; this is in hopes that one will expand on it or maybe some other novice may use it as I do. At the top of my.php files I put:
<?php
// Create document
$impl = new DOMImplementation();
$doctype = $impl->createDocumentType("html",
"-//W3C//DTD XHTML 1.0 Strict//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
$document = $impl->createDocument(null, null, $doctype);
//this line creates a closing tag for html element which is why i have hard-coded
//the namespace attribute in the opening tag below
//$document = $impl->createDocument('http://www.w3.org/1999/xhtml', 'html', $doctype);
echo $document->saveXML();
//
echo "<html xmlns='http://www.w3.org/1999/xhtml'>";
[...]
includes that contains:
$pubId = $doctype->publicId;
switch($pubId) {
case '-//W3C//DTD HTML 4.01//EN' :
include_once('valhtml401strict.inc');
break;
case '-//W3C//DTD XHTML 1.0 Strict//EN' :
include_once('valxhtml10strict.inc');
break;
case null ://html5
include_once('valxhtml10strict.inc');
break;
default:
include_once('valxhtml10strict.inc');
break;
}