當網頁執行時經常出現以下情形訊息時
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\excel.php:1) in C:\AppServ\www\excel.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\excel.php:1) in C:\AppServ\www\excel.php on line 3
當網頁執行時經常出現以上情形時, 可試著修改 php.ini 內的設定. (php.ini 位於 $WINDOWS下)
然後確認是否 output_buffering 的參數有被設定。
在Appserv 2.5.7 中 output_buffering 預設是被設成 Off 的,如下說明。
; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).
output_buffering = Off
解決方法 : 將 output_buffering 的值設成4096或以上然後重新啟動Apache即可解決問題
補充: header 在送出之前不能用任何內容輸出, 可能會造成問題