Example: Creating an XHTML document from PHP
<?php
if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
header('Content-Type: application/xhtml+xml; charset=utf-8');
}
else {
header('Content-Type: text/html; charset=utf-8');
}
$doctype = '<?xml version="1.0" encoding="UTF-8"?>';
$head= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
$head .= ' <head>';
$head .= ' <title>Document Type Declaration Example</title>';
$head .= ' </head>';
$body = ' <body>';
$body .= ' <p>The content of the page goes here.</p>';
$body .= ' </body>';
$footer = '</html>';
echo $doctype;
echo $head;
echo $body;
echo $footer;
?>
Related examples in the same category