Example: Creating an XHTML document from PHP : HTML « HTML « PHP






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

1.Display of HTML using PHP code
2.Dynamic Generation of Tags from an Array
3.Dynamic HTML tags
4.Dynamic PHP page creation
5.Dynamic date insertion
6.Output Control
7.Output image tag
8.Output image tag with global path value
9.The Header