简体   繁体   中英

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. environment. In the php.ini is set: error_reporting = E_ALL

With this code I'm expecting the warning: "Cannot modify header information - headers already sent by..."

<?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. What should I change, that I will get this warning too on my XAMPP installation? 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.

Thank you very much for your help.

Your ISP has output buffering disabled. On your XAMPP installation it's enabled. Outputting content before sending headers will not generate the warning unless content length exceeds configured output_buffering value (4096 by default). https://www.php.net/manual/en/outcontrol.configuration.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM