Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 276
Ben Dauphinee Avatar asked Jan 19 '11 15:01

Ben Dauphinee


People also ask

What is Ob_start () and Ob_end_flush () in PHP?

While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer. The contents of this internal buffer may be copied into a string variable using ob_get_contents(). To output what is stored in the internal buffer, use ob_end_flush().

What is Ob_end_flush?

The ob_end_flush() function deletes the topmost output buffer and outputs all of its contents. The output may be caught by another output buffer, or, if there are no other output buffers, sent directly to the browser.

What is the use of Ob_start () in PHP?

The ob_start() function creates an output buffer. A callback function can be passed in to do processing on the contents of the buffer before it gets flushed from the buffer. Flags can be used to permit or restrict what the buffer is able to do.

What is use of Ob_end_clean in PHP?

The ob_end_clean() function deletes the topmost output buffer and all of its contents without sending anything to the browser.


1 Answers

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

like image 51
ircmaxell Avatar answered Sep 25 '22 05:09

ircmaxell