簡體   English   中英

PHP 重現警告“無法修改 header 信息 - 標頭已由(輸出開始於...”與 XAMPP 8..1.1

[英]PHP reproduce warning "Cannot modify header information - headers already sent by (output started at... " with XAMPP 8..1.1

我正在使用 XAMPP 8.1.1 作為開發人員。 環境。 在 php.ini 中設置:error_reporting = E_ALL

使用此代碼,我期待警告:“無法修改 header 信息 - 標頭已由...發送”

<?php
echo 'It works!<br>';
//Expected Warning "Cannot modify header information - headers already sent by"
header ('Content-Type: text/html; charset=utf-8');

echo '<br>...not!';
?>

如果我將此 function 稱為我的 ISP,我會收到警告,但不會在我的 XAMPP 安裝中。 我應該改變什么,我也會在我的 XAMPP 安裝中收到這個警告? 我無法訪問我的 ISP 處的 php.ini 文件來比較設置,我發現的只是錯誤報告不那么嚴格,但是在我的 XAMPP 上使用相同的設置,我什至沒有得到警告。

非常感謝您的幫助。

您的 ISP 禁用了 output 緩沖。 在您的 XAMPP 安裝上,它已啟用。 在發送標頭之前輸出內容不會產生警告,除非內容長度超過配置的output_buffering值(默認為 4096)。 https://www.php.net/manual/en/outcontrol.configuration.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM