a) Am I right in assuming the correct format for script in head in HTML5 is ?
b) How do I achieve the correct result using the DOMDocument?
$domImplementation = new \DOMImplementation ();
$docType = $domImplementation->createDocumentType ( 'html', '', '' );
$document = $domImplementation->createDocument ( 'http://www.w3.org/1999/xhtml', 'html', $docType );
$head = $document->createElement ( 'head' );
$script = $document->createElement ( 'script', '' );
$script->setAttribute ('src', 'script.js');
$head->appendChild ( $script );
produces
The HTML5 validator says
Self-closing syntax (/>) used on a non-void HTML element. Ignoring the slash and treating as a start tag.