开发者

PHP 5.3 now allows redirects after writing content?

I recently made the jump from php 5.2 to 5.3, and I've noticed that it will now allow redirects (ie. headers) after writing cont开发者_JAVA技巧ent, presumably through some sort of automatic output buffering.

I used to think it was annoying the other way... but this makes it much harder to track down errors during development. Is there a way to turn this option off in my php.ini file? Or is there a compelling reason to leave it, and I'll just learn to expect this behavior over time?


output_buffering = off

In response to your second question, you should leave OB off. If you're in a situation where it is useful or necessary you can always turn it on using ob_start() in your code. If you leave it on in php.ini PHP will buffer all of your output, which can be annoying at times (its messed up my Ajax responses before too) especially if you forget to flush() at the end.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜