Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing "headers already sent"-warning on output before header

Tags:

php

header

I know there are lots of threads about headers already sent output, but i have a strange effect on my Debian VM (PHP Version 5.3.3-7+squeeze15)

The following code works although it should not work!

<?php
echo "test";
header("Location:http://www.example.com");
?>

Does anybody know why it works and i dont get an "headers already sent warning"?

like image 499
steven Avatar asked Mar 03 '26 15:03

steven


1 Answers

From the php.ini file comments for the setting output_buffering:

; Output buffering is a mechanism for controlling how much output data
; (excluding headers and cookies) PHP should keep internally before pushing that
; data to the client. If your application's output exceeds this setting, PHP
; will send that data in chunks of roughly the size you specify.

; Turning on this setting and managing its maximum buffer size can yield some
; interesting side-effects depending on your application and web server.
; **You may be able to send headers and cookies after you've already sent output**
; through print or echo. You also may see performance benefits if your server is
; emitting less packets due to buffered output versus PHP streaming the output
; as it gets it. On production servers, 4096 bytes is a good setting for performance
; reasons.
like image 180
RMcLeod Avatar answered Mar 05 '26 04:03

RMcLeod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!