我在嘗試添加表格的新行時遇到錯誤,一切正常,我可以將我的 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>我已經(jīng)完成導出,直到我添加新的表行,我收到上面的錯誤
1 回答

aluckdog
TA貢獻1847條經(jīng)驗 獲得超7個贊
請參閱文檔:
header() 必須在發(fā)送任何實際輸出之前調(diào)用,無論是通過正常的 HTML 標簽、文件中的空行還是從 PHP 發(fā)送。使用 include、require、函數(shù)或其他文件訪問函數(shù)讀取代碼,并在調(diào)用 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 關注
- 99 瀏覽
添加回答
舉報
0/150
提交
取消