public static function format($format = 'html', $charset = NULL) { global $_G; self::$charset = $charset = $charset ? strtolower($charset) : $_G['product']['charset']; self::$format = $format; //关闭缓冲 //ob_end_clean(); switch ($format) { case 'xml': header('Content-Type: text/xml; charset=' . $charset); break; case 'html': header('Content-type: text/html; charset=' . $charset); break; case 'json': header('Content-type: text/javascript; charset=' . $charset); break; case 'csv': header("Cache-Control: public"); header("Content-type:application/msexcel; charset=" . $charset); header("Accept-Ranges: bytes"); break; case 'attachment': header("Cache-Control: public"); header("Content-type:application/octet-stream; charset=" . $charset); header("Accept-Ranges: bytes"); break; default: case 'text': header('Content-Type: text/plain; charset=' . $charset); break; } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php Output::charset(); ?> <title><?php Output::title(); ?> </title> <?php Output::meta('author', 'caleng'); Output::keywords(); Output::description(); Output::importJS(); Output::importCSS(); ?> </head> <body> <?php include_once $TEMPLATE_FILE; ?> </body> </html>