首頁 php教程 php手册 php中使用header函数后,页面提示:Warnging: Cannot modify hea

php中使用header函数后,页面提示:Warnging: Cannot modify hea

Jun 06, 2016 pm 07:53 PM
header php 使用 函數 提示 頁面

Warning: Cannot modify header information - headers already sent by 的原因 我的php程序调用了header(Location: www.baidu.com );函数, 运行后出现出现 Warning: Cannot modify header information - headers already sent by 的页面警告。 发现原来是

 

Warning: Cannot modify header information - headers already sent by 的原因

我的php程序调用了header("Location:www.baidu.com");函数,

运行后出现出现 Warning: Cannot modify header information - headers already sent by 的页面警告。

发现原来是我的php.ini里面的配置的问题,

默认的php.ini文件中,output_buffering指令选项的默认值为off。

把它设为4096就解决了显示提示warning错误的提示。.

php.ini 文件对 output_buffering指令选项做了详细说明如下:

 

  94 ; Output buffering allows you to send header lines (including cookies) even
  95 ; after you send body content, at the price of slowing PHP's output layer a
  96 ; bit.  You can enable output buffering during runtime by calling the output
  97 ; buffering functions.  You can also enable output buffering for all files by
  98 ; setting this directive to On.  If you wish to limit the size of the buffer
  99 ; to a certain size - you can use a maximum number of bytes instead of 'On', as
 100 ; a value for this directive (e.g., output_buffering=4096).
 101 #output_buffering = Off
 102  output_buffering = 4096
登入後複製

最后,重启,使修改后的配置文件生效。

在Linux下,

如果因PHP命令行而修改php.ini 则不需要重启;

如果因Apache而修改php.ini,则需要重启apache服务;

总之,就是那个服务使用了php,就重新启动该服务,就可以了。


 

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

適用於 Ubuntu 和 Debian 的 PHP 8.4 安裝和升級指南 適用於 Ubuntu 和 Debian 的 PHP 8.4 安裝和升級指南 Dec 24, 2024 pm 04:42 PM

PHP 8.4 帶來了多項新功能、安全性改進和效能改進,同時棄用和刪除了大量功能。 本指南介紹如何在 Ubuntu、Debian 或其衍生版本上安裝 PHP 8.4 或升級到 PHP 8.4

CakePHP 日期和時間 CakePHP 日期和時間 Sep 10, 2024 pm 05:27 PM

為了在 cakephp4 中處理日期和時間,我們將使用可用的 FrozenTime 類別。

CakePHP 檔案上傳 CakePHP 檔案上傳 Sep 10, 2024 pm 05:27 PM

為了進行文件上傳,我們將使用表單助理。這是文件上傳的範例。

討論 CakePHP 討論 CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP 是 PHP 的開源框架。它旨在使應用程式的開發、部署和維護變得更加容易。 CakePHP 基於類似 MVC 的架構,功能強大且易於掌握。模型、視圖和控制器 gu

CakePHP 建立驗證器 CakePHP 建立驗證器 Sep 10, 2024 pm 05:26 PM

可以透過在控制器中新增以下兩行來建立驗證器。

CakePHP 日誌記錄 CakePHP 日誌記錄 Sep 10, 2024 pm 05:26 PM

登入 CakePHP 是一項非常簡單的任務。您只需使用一項功能即可。您可以記錄任何後台程序(如 cronjob)的錯誤、異常、使用者活動、使用者採取的操作。在 CakePHP 中記錄資料很容易。提供了 log() 函數

如何設定 Visual Studio Code (VS Code) 進行 PHP 開發 如何設定 Visual Studio Code (VS Code) 進行 PHP 開發 Dec 20, 2024 am 11:31 AM

Visual Studio Code,也稱為 VS Code,是一個免費的原始碼編輯器 - 或整合開發環境 (IDE) - 可用於所有主要作業系統。 VS Code 擁有大量針對多種程式語言的擴展,可以輕鬆編寫

CakePHP 快速指南 CakePHP 快速指南 Sep 10, 2024 pm 05:27 PM

CakePHP 是一個開源MVC 框架。它使應用程式的開發、部署和維護變得更加容易。 CakePHP 有許多函式庫可以減少大多數常見任務的過載。

See all articles