繁体   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