PHP ob_list_handlers() Function
Last Updated :
11 Apr, 2023
The ob_list_handlers() function is an inbuilt function in PHP that enumerates all output handlers currently in use.
Syntax:
ob_list_handlers(): array
Parameter: This function does not have any parameters.
Return Values: The function will return an array containing the names of all output buffering handlers that are currently installed and available for use. Each element in the array represents the name of an installed output buffering handler, and the order of the elements in the array corresponds to the order in which the handlers were installed.
Example 1: The following code demonstrates the ob_list_handlers() function.
PHP
<?php
if (in_array( 'ob_gzhandler' , ob_list_handlers())) {
echo "The ob_gzhandler output buffer handler is enabled." ;
} else {
echo "The ob_gzhandler output buffer handler is not enabled." ;
}
?>
|
Output:
The ob_gzhandler output buffer handler is not enabled.
Example 2: The following code also demonstrates the ob_list_handlers() function.
PHP
<?php
ob_start( 'mb_output_handler' ) ;
$handlers = ob_list_handlers();
echo "Available output buffer handlers:\n" ;
foreach ( $handlers as $handler ) {
echo "- $handler\n" ;
}
?>
|
Output:
Available output buffer handlers:
- mb_output_handler
Reference: https://www.php.net/manual/en/function.ob-list-handlers.php
Share your thoughts in the comments
Please Login to comment...