setcookie語句的問題_PHP教程

來源:互聯網
上載者:User

出現的錯誤提示:

Warning: Cannot modify header information - headers already sent by

解決辦法:

開啟php_ini,搜尋output_bufferfing,把前面的分號去掉,把off修改為on,或者設定一個數值。就可以了。

這類語句,造成這個原因是因為setcookie語句的問題。

cookie本身在使用上有一些限制,例如:
1.呼叫setcookie的?述必?放在標籤之前
2.呼叫setcookie之前,不可使用echo
3.直到??被重新?入後,cookie才?在程式中出?
4.setcookie函數必?在任何?料?出至瀏覽器前,就先送出
5.……

基於上面?些限制,所以?行setcookie()函數時,常?碰到”Undefined index”、”Cannot modify header information - headers already sent by”…等??,解?”Cannot modify header information - headers already sent by”這個??的方法是在產生cookie前,先延緩?料輸出至瀏覽器,因此,您可以在程式的最前方加上ob_start();這個函?。這樣就可以解決了。

http://www.bkjia.com/PHPjc/508261.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/508261.htmlTechArticle出現的錯誤提示: Warning: Cannot modify header information - headers already sent by 解決辦法: 開啟php_ini,搜尋output_bufferfing,把前面的分號去掉,把off修...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.