方案一

$html2 ='数字'; 

header("Content-type: application/octet-stream"); 
header("Accept-Ranges: bytes"); 
header("Accept-Length: ".strlen($html2));
header('Content-Disposition: attachment; filename=test.doc'); 
header("Pragma:no-cache"); 
header("Expires:0"); 
echo $html2;
//此方法是放入缓冲区输出, 默认4096. 超出自动就输出到浏览器上了。 可以修改配置文件 output_buffering = 4096 改成 On (无限大)

$html2 = '实验中学'; 

echo $html2;

ob_start();
header("Content-type: application/octet-stream"); 
header("Accept-Ranges: bytes"); 
header("Accept-Length: ".strlen($html2));
header('Content-Disposition: attachment; filename=test.doc'); 
header("Pragma:no-cache"); 
header("Expires:0"); 
ob_end_clean();

 

posted on 2014-12-01 11:31  睡着的糖葫芦  阅读(6504)  评论(0编辑  收藏  举报