2007-09-04, 02:28 PM
In my opinion a browser should get the most appropriate content and if it accepts application/xhtml+xml, all pages should have that content type (as suggested here: http://www.w3.org/TR/xhtml-media-types/)
I personally use the following snippet to check whether or not the browser accepts application/xhtml+xml and send the appropriate header.
Furthermore the current content type needs to be inserted dynamically in the meta tag, as you are doing already with the charset.
Quote:In summary, 'application/xhtml+xml' SHOULD be used for XHTML Family documents,...
I personally use the following snippet to check whether or not the browser accepts application/xhtml+xml and send the appropriate header.
if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1') {
if(isset($_SERVER['HTTP_ACCEPT']) && preg_match('|application/xhtml\+xml(?!\s*;\s*q=0)|', $_SERVER['HTTP_ACCEPT'])) {
header('Content-Type: application/xhtml+xml; charset=utf-8');
} else {
header('Content-Type: text/html; charset=utf-8');
}
header('Vary: Accept');
} else {
header('Content-Type: text/html; charset=utf-8');
}
Furthermore the current content type needs to be inserted dynamically in the meta tag, as you are doing already with the charset.