PHP ob_list_handlers() Function
The PHP ob_list_handlers() function returns an array with the names of the callback functions that were passed into the ob_start() function of the topmost output buffer.
If output_buffering is enabled or an anonymous function was used with ob_start(), this function returns "default output handler".
Syntax
ob_list_handlers()
Parameters
No parameter is required.
Return Value
Returns an array with the output handlers in use (if any). If output_buffering is enabled or an anonymous function was used with ob_start(), it returns "default output handler".
Example: ob_list_handlers() example
The example below shows the usage of ob_list_handlers() function.
<?php //using ob_gzhandler() function ob_start("ob_gzhandler"); print_r(ob_list_handlers()); ob_end_flush(); //using anonymous functions ob_start(function($string) {return $string;}); print_r(ob_list_handlers()); ob_end_flush(); ?>
The output of the above code will be:
Array ( [0] => ob_gzhandler ) Array ( [0] => Closure::__invoke )
Example: using output_buffering=On
Consider one more example where this function is used with output_buffering=On. Please note that the output_buffering=On can be set in php.ini.
<?php //using output_buffering=On print_r(ob_list_handlers()); ob_end_flush(); ?>
The output of the above code will be:
Array ( [0] => default output handler )
❮ PHP Output Control Reference