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
php"> $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实现针对日期,月数,天数,周数,小时,分,秒等的加减运算示例【基于strtotime】 2022-08-01
- PHP根据出生日期计算年龄 2022-07-15
- php实现数组分组简单的一个代码实例 2022-08-01
- Ajax跨域请求PHP header设置 2022-10-13
- PC端微信扫码支付成功之后怎么自动跳转的代码 2022-08-11
- PHP正则表达式匹配是否为IP地址段的实例代码 2023-07-08
- php将文本内容导出为word文档,php导出doc文档 2022-09-18
- php采集图片的一个实例代码 2022-12-19
- PHP正则匹配日期和时间(时间戳转换)的实例代码 2022-07-22
- phpword读取内容和样式 生成新的内容 2022-09-23
