php将html转成word文档下载

<meta charset="utf-8" />
<?php
class word{
function start(){
ob_start();
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">';
}
function save($path)
{
echo "</html>";
$data = ob_get_contents();
}
function wirtefile($fn,$data){
$fp=fopen($fp,$data);
fwrite($fp,$data);
}
}
$html='
这里是html的内容
<form action="ceshi.php" method="post">
<button name="aa" value="cc">转换成word文档</button>
</form>
'; //批量生成
//for($i=1;$i<3;$i++){
$word = new word();
$word->start();
$wordname='word.doc';
echo $html; $aa = "cc"; if($aa=@$_POST['aa']){
//echo @$aa; //$word->save($wordname);
@header('Content-type:application/word');
header('Content-Disposition: attachment; filename='.$wordname.'');
@readfile($wordname);
ob_flush();//每次执行前刷新缓存
flush();
//}
}else{
echo "";
}
?>
上一篇:windows下python的包管理器pip安装


下一篇:iOS UIPageViewController缺陷