phpoutput-bufferingdie

Does die() do an ob_end_flush()?


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?


Solution

  • 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...