Kalko Kalko - 4 months ago 5x
PHP Question

How can I set an output buffer name in php?

I have been browsing the documentation for PHP's ob_get_status function and found the following:

Return Values:

If called without the full_status parameter or with full_status =
FALSE a simple array with the following elements is returned:

Array (
[level] => 2
[type] => 0
[status] => 0
[name] => URL-Rewriter
[del] => 1

All seems pretty clear, however all of the internets seem to be unable to answer one question that arose - how can I set the name of an output buffer?

Is it even possible to do it? I coudln't find any clue in the documentation itself, or anywhere else.
However the documentation mentions that

name = Name of active output handler or ' default output handler' if
none is set

which pretty much implies it is possible to set it somehow.

Do you guys have any idea if this can be done? Any help would be greatly apprieciated.


By using ob_start you can turn on the output buffering in PHP.

Note that the function has such signature:

bool ob_start ([ callable $output_callback = NULL [, int $chunk_size = 0 [, int $flags = PHP_OUTPUT_HANDLER_STDFLAGS ]]] )

You can pass named function as a valid callback.

For example:


function test_handler($a) {
    return $a;



Will give you:

array(7) {
  string(12) "test_handler"