[英]PHP reproduce warning "Cannot modify header information - headers already sent by (output started at... " with XAMPP 8..1.1
I'm using XAMPP 8.1.1 as dev.我正在使用 XAMPP 8.1.1 作为开发人员。 environment.
环境。 In the php.ini is set: error_reporting = E_ALL
在 php.ini 中设置:error_reporting = E_ALL
With this code I'm expecting the warning: "Cannot modify header information - headers already sent by..."使用此代码,我期待警告:“无法修改 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!';
?>
If I call this function my ISP, I will get the warning, but not on my XAMPP installation.如果我将此 function 称为我的 ISP,我会收到警告,但不会在我的 XAMPP 安装中。 What should I change, that I will get this warning too on my XAMPP installation?
我应该改变什么,我也会在我的 XAMPP 安装中收到这个警告? I don't have access to the php.ini File at my ISP to compare the settings, all I found out, is that the error reporting is a little bit less strict, but with the same settings on my XAMPP, I do even not get the warning.
我无法访问我的 ISP 处的 php.ini 文件来比较设置,我发现的只是错误报告不那么严格,但是在我的 XAMPP 上使用相同的设置,我什至没有得到警告。
Thank you very much for your help.非常感谢您的帮助。
Your ISP has output buffering disabled.您的 ISP 禁用了 output 缓冲。 On your XAMPP installation it's enabled.
在您的 XAMPP 安装上,它已启用。 Outputting content before sending headers will not generate the warning unless content length exceeds configured
output_buffering
value (4096 by default).在发送标头之前输出内容不会产生警告,除非内容长度超过配置的
output_buffering
值(默认为 4096)。 https://www.php.net/manual/en/outcontrol.configuration.php https://www.php.net/manual/en/outcontrol.configuration.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.