2013年7月1日 星期一

2013 / 07 / 02 PHP小記(session & header出錯)

先前寫的網頁,整組好好的網頁,突然一次蹦~都發生error。
好像養了個不定時炸彈在web server。

Error Messige

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/Vexed/index.php:10) in/home/Vexed/index.php on line 9

Warning: Cannot modify header information - headers already sent by (output started at /home/Vexed/index.php:10) in /home/Vexed/index.php on line 9


網路上各種Answer,以下為使用成功。
1.PHP header/session_start() 前面不可以有輸出。
 →把session_start()移到<html>前面解決。
來源:https://sites.google.com/site/altohornubuntu/home/06-cheng-shi-she-ji/warningsessionstartfunctionsession-startcannotsendsessioncachelimiter
2.PHP文件格式為UTF-8
 →把session_start();改成@session_start();
來源:https://sites.google.com/site/altohornubuntu/home/06-cheng-shi-she-ji/warningsessionstartfunctionsession-startcannotsendsessioncachelimiter


Header出錯我是選擇換個跳頁方法。
把header改成meta


2. Meta
echo '<meta http-equiv="refresh" content="0;url=http://disp.cc">';
content 裡面那個 0 代表馬上跳轉,可以改成要幾秒後再跳轉


來源:http://disp.cc/b/11-4Gz9

沒有留言:

張貼留言