我在尝试添加表格的新行时遇到错误,一切正常,我可以将我的 html 页面导出到 MS Word。我收到这样的错误Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\exportword2.php:216) in C:\xampp\htdocs\test\exportword2.php on line 217Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\exportword2.php:216) in C:\xampp\htdocs\test\exportword2.php on line 218Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\exportword2.php:216) in C:\xampp\htdocs\test\exportword2.php on line 219Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\exportword2.php:216) in C:\xampp\htdocs\test\exportword2.php on line 220这是我的代码 <tr> <td>13. </td> <td>Upah Pekerja</td> <td>:</td> <td>Minimum</td> <td colspan="4">Rp. 100000</td> </tr> <tr> <td></td> <td></td> <td>:</td> <td>Maximum</td> <td colspan="4">Rp. 100000</td> </tr> <tr> <td></td> <td>Upah Pekerja Harian</td> <td>:</td> <td>Minimum</td> <td colspan="4">Rp. 100000</td> </tr> <tr> <td></td> <td></td> <td>:</td> <td>Maximum</td> <td colspan="4">Rp. 100000</td> </tr> <tr> <td>14.</td> <td>Sistem Hubungan Kerja</td> <td colspan="6">:</td> </tr> <tr> <td></td> <td>a. Untuk Waktu Tertentu</td> <td colspan="6">: 3 Orang</td> </tr> <tr> <td></td> <td>b. Untuk Waktu Tidak Tertentu</td> <td colspan="6">: 3 Orang</td> </tr> </table>我已经完成导出,直到我添加新的表行,我收到上面的错误
1 回答
aluckdog
TA贡献1847条经验 获得超7个赞
请参阅文档:
header() 必须在发送任何实际输出之前调用,无论是通过正常的 HTML 标签、文件中的空行还是从 PHP 发送。使用 include、require、函数或其他文件访问函数读取代码,并在调用 header() 之前输出空格或空行是一个非常常见的错误。使用单个 PHP/HTML 文件时也存在同样的问题。
<?php
// header must be before any sent output
header("Content-Type: application/vnd.msword");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=hasilekspor.doc");
?>
<html>
...
</html>
- 1 回答
- 0 关注
- 73 浏览
添加回答
举报
0/150
提交
取消