PHP将HTML页面输出为word文档,具体实例代码如下:PHP将HTML页面输出为word文档,具体实例代码如下: $html = include ('html文件');echo $html; ob_start(); //打开缓冲区 header("Cache-Control: public"); Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes"); $riqi=date("Ymd"); if (strpos($_SERVER["HTTP_USER_A
$html = include ('html文件');
echo $html;
ob_start(); //打开缓冲区
header("Cache-Control: public");
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
$riqi=date("Ymd");
if (strpos($_SERVER["HTTP_USER_AGENT"],'MSIE')) {
header('Content-Disposition: attachment; filename='.$riqi.'.doc');
}else if (strpos($_SERVER["HTTP_USER_AGENT"],'Firefox')) {
Header('Content-Disposition: attachment; filename='.$riqi.'.doc');
} else {
header('Content-Disposition: attachment; filename='.$riqi.'.doc');
}
header("Pragma:no-cache");
header("Expires:0");
ob_end_flush();//输出全部内容到浏览器
//内容过大输出失败, 请修改php.ini output_buffering
沃梦达教程
本文标题为:PHP将HTML页面输出为word文档的办法


基础教程推荐
猜你喜欢
- PHP实现根据数组的值进行分组 2022-08-01
- php利用函数获取两个数组中不同元素的个数 2024-12-04
- php利用函数将二进制转为字符串的两种方法 2024-12-04
- 前端用PHP写简单的删除接口(三) 2024-12-04
- 基于PHP+MySQL的简单聊天室思路与代码 2022-08-27
- php基于文本搜索的实例代码 2022-08-22
- 掌握php六大关键字 2024-12-04
- php利用for语句和substr()函数怎么实现字符串的反转 2024-12-04
- php怎么判断一个数组中的元素是否完全属于另一个数组 2024-12-04
- php如何利用函数修改时差 2024-12-05