Posted by Tom Morris on Tue 23 Oct 11:01 (modification of post by Tom Morris view diff)
report abuse | download | new post
- // tom morris - tommorris.org
- // invoke with ob_start("callback"); ... ob_end_flush();
- function callback($buffer) {
- $output = SmartyPants($buffer);
- // get the default mime type accepted by browser
- $defaultmime = mimeTypeChecker($_SERVER);
- // load into DOM and test
- $domtest = new DOMDocument('1.0');
- if (@$domtest->loadXML($output) == TRUE) {
- $mime = $defaultmime;
- } else {
- $mime = "text/html";
- }
- // return headers
- return $output;
- }
- // uses mimeTypeChecker... thus included below. i didn't write
- // this, cant remember where i took it from
- function mimeTypeChecker($server) {
- $mime = 'text/html';
- $mime = 'application/xhtml+xml';
- } else {
- if(preg_match("/application\/xhtml\+xml;q=([01]|0\.\d{1,3}|1\.0)/i", $server['HTTP_ACCEPT'], $matches)) {
- $xhtml_q = $matches[1];
- $html_q = $matches[1];
- if((float)$xhtml_q >= (float)$html_q) {
- $mime = 'application/xhtml+xml';
- }
- }
- } else {
- $mime = 'application/xhtml+xml';
- }
- }
- }
- return $mime;
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.