I can't seem to find a good answer on this anywhere. If I am running output buffering, and a die()
is fired, does that kick off an ob_end_flush()
as well?
Asked
Active
Viewed 988 times
8

yoozer8
- 7,361
- 7
- 58
- 93

Ben Dauphinee
- 4,061
- 8
- 40
- 59
-
2I do see pending buffers when the script ends (die or not die, CLI or HTTP). I don't know if it's documented and/or configurable; I agree it'd be interesting to find an explicit reference to it in the manual. – Álvaro González Jan 19 '11 at 15:20
2 Answers
14
Yes it does. Any time the script ends gracefully, the buffers will be emptied. The only non-graceful endings are if it segmentation faults or if it's killed (signal 9 SIG_KILL). The only place that die()
does a hard-kill of the process is if you call it inside of a register_shutdown_function
(But the buffers are flushed before the shutdown function is called, so there's no issue there). See Connection Handling for some more information...

ircmaxell
- 163,128
- 34
- 264
- 314
0
Yes.
However, you can make the output empty if you have
register_shutdown_function('ob_clean');
earlier in the code.
In some cases we did not want to output the ob on a die(). I write this here in case it could help anyone who wants to do the same.

Simon
- 66
- 5