Files
selima-perl/lib/php/monica/xhtml.inc.php
2026-03-10 21:31:43 +08:00

29 lines
1.0 KiB
PHP

<?php
// File name: xhtml.inc.php
// Description: Extended PHP subroutine to read from/write to a file
// Date: 2004-12-29
// Author: imacat <imacat@pristine.com.tw>
// Copyright: Copyright (C) 2004-2007 Pristine Communications
// xhtml_content_type: Check whether application/xhtml+xml or text/html
// should be sent to the client
function xhtml_content_type()
{
// Browsers that claim to support application/xhtml+xml explicitly
if ( array_key_exists("HTTP_ACCEPT", $_SERVER)
&& strpos($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml") !== false) {
return "application/xhtml+xml";
}
// Browsers that are known to support application/xhtml+xml
if (array_key_exists("HTTP_USER_AGENT", $_SERVER)) {
// W3C validator can recognize application/xhtml+xml
if (substr($_SERVER["HTTP_USER_AGENT"], 0, 13) == "W3C_Validator") {
return "application/xhtml+xml";
}
}
// Else, we assume that application/xhtml+xml is not supported
return "text/html";
}
?>