缺少"标题已发送" - 在标题之前输出警告

ste*_*ven 2 php header

我知道有很多关于已经发送输出的头文件的线程,但我对我的Debian VM有一个奇怪的影响(PHP Version 5.3.3-7 + squeeze15)

以下代码有效,但它不起作用!

<?php
echo "test";
header("Location:http://www.example.com");
?>
Run Code Online (Sandbox Code Playgroud)

有谁知道它为什么有效,我没有得到"标题已发送警告"?

RMc*_*eod 7

php.ini设置的文件注释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.
Run Code Online (Sandbox Code Playgroud)