文件名稱: Cannot add header information.

簡短描述: Cannot add header information 是常見的訊息,這裡提供幾個解決方法

--------------------------------------------------------------------------------



Cannot add header information 是常見的訊息,最常見的情形如下:

Warning: Cannot add header information - headers already sent by (output started at /usr/local/psa/home/vhosts/xxx.com/httpdocs/header.php:32) in /usr/local/psa/home/vhosts/xx.com/httpdocs/includes/sessions.php on line 251



這裡提供幾個解決方法,不見得所有此類錯誤訊息都管用,但至少可解決部份問題:



方法一:

在你的Nuke根目錄的.htaccess 檔內加入:

PHP_FLAG output_buffering on



方法一:

在你的header.php檔頭加入:ob_start();

資料來源:http://www.wyjh.mlc.edu.tw/winpon/modules.php?name=MyArchives&op=ViewItems&vid=67







解決來源2

[PHP] 惱人的 Warning: Cannot add header information - headers already sent by ....

寫過 PHP 的人一定看過這個訊息..



Warning: Cannot add header information - headers already sent by ..



有空再解釋原理及發生的原因,一般可以用 PHP 的 ob 系列函數來處理,但是比較簡單的方式也可以用打開 PHP Output buffer 的方式來解決。



打開的方法:



方法1.在 php.ini 裡面找到 output_buffering ,並改為1。



方法2.由於虛擬主機不可能改 php.ini ,因此只要在自己網站的根目錄新增一個 .htaccess 的檔案,並且加入下面這一行:





PHP_FLAG output_buffering On



這個方法跟 apache 的 .htaccess AllowOverride 權限有關,所以如果用 phpinfo(); 看還是沒有的話,就要先在 .htaccess 裡面改為:





AllowOverride Options

PHP_FLAG output_buffering On







AllowOverride All

PHP_FLAG output_buffering On



這樣看看有沒有 HTTP 500 Error 的錯誤訊息,如果有的話,就可能要請主機商打開 .htaccess AllowOverride 了。



資料來源:http://www.neo.com.tw/archives/000313.html


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 killworm737 的頭像
    killworm737

    紀錄些小事情

    killworm737 發表在 痞客邦 留言(1) 人氣()