Skip to content

Instantly share code, notes, and snippets.

@zubinJiang
Created October 19, 2012 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zubinJiang/3916776 to your computer and use it in GitHub Desktop.
Save zubinJiang/3916776 to your computer and use it in GitHub Desktop.
php 发送header头文件
<?php
ob_start(); //打开缓冲区
Header("Cache-Control: public");
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
if (strpos($_SERVER["HTTP_USER_AGENT"],'MSIE')) {
Header('Content-Disposition: attachment; filename=test.php');
}else if (strpos($_SERVER["HTTP_USER_AGENT"],'Firefox')) {
Header('Content-Disposition: attachment; filename=test.doc');
} else {
Header('Content-Disposition: attachment; filename=test.doc');
}
Header("Pragma:no-cache");
Header("Expires:0");
echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<xml><w:WordDocument><w:View>Print</w:View></xml>
<script src="includes/js/ztree/js/jquery-1.4.4.min.js" type="text/javascript"></script>
</head>';
echo '<body><table class="table_dayin"><caption class="table_caption">';
echo "数字化教学系统电子备课稿<br><span>学科 <em style=\"border-bottom: 1px solid #545454;\">语文</em>学校 <em style=\"border-bottom: 1px solid #545454;\">实验中学</em></span></caption>";
echo '</table></body></html>';
ob_end_flush();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment