is at the top as opposed # to a line (preferably after ?) # # This happens regardless if it's utf-8 or iso-8859-1 $charset = "utf-8"; $mime = "text/html"; function fix_code($buffer) { return (str_replace(" />", ">", $buffer)); } if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) { # if there's a Q value for "application/xhtml+xml" then also # retrieve the Q value for "text/html" if(preg_match("/application\/xhtml\+xml;q=0(\.[1-9]+)/i", $_SERVER["HTTP_ACCEPT"], $matches)) { $xhtml_q = $matches[1]; if(preg_match("/text\/html;q=0(\.[1-9]+)/i", $_SERVER["HTTP_ACCEPT"], $matches)) { $html_q = $matches[1]; # if the Q value for XHTML is greater than or equal to that # for HTML then use the "application/xhtml+xml" mimetype if($xhtml_q >= $html_q) { $mime = "application/xhtml+xml"; } } # if there was no Q value, then just use the # "application/xhtml+xml" mimetype } else { $mime = "application/xhtml+xml"; } } # special check for the W3C_Validator if (stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator")) { $mime = "application/xhtml+xml"; } # set the prolog_type according to the mime type which was determined if($mime == "application/xhtml+xml") { $prolog_type = " "; } else { ob_start("fix_code"); $prolog_type = " "; } # finally, output the mime type and prolog type header("Content-Type: $mime;charset=$charset"); header("Vary: Accept"); print $prolog_type; ?>