ob_list_handlers

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

ob_list_handlers列出所有使用中的輸出處理程序。

說明

ob_list_handlers(): array

列出所有使用中的輸出處理程序。

返回值

此函數(shù)將返回一個數(shù)組,數(shù)組元素是正在使用中輸出處理程序名(如果存在的輸出處理程序的話)。 如果啟用了output_buffering 或者在 ob_start() 中創(chuàng)建了一個匿名函數(shù),ob_list_handlers() 將返回 "default output handler"。

范例

示例 #1 ob_list_handlers() example

<?php
//using output_buffering=On
print_r(ob_list_handlers());
ob_end_flush();

ob_start("ob_gzhandler");
print_r(ob_list_handlers());
ob_end_flush();

// anonymous functions
ob_start(create_function('$string''return $string;'));
print_r(ob_list_handlers());
ob_end_flush();
?>

以上例程會輸出:

Array
(
    [0] => default output handler
)

Array
(
    [0] => ob_gzhandler
)

Array
(
    [0] => default output handler
)

參見

  • ob_end_clean() - 清空(擦除)緩沖區(qū)并關(guān)閉輸出緩沖
  • ob_end_flush() - 沖刷出(送出)輸出緩沖區(qū)內(nèi)容并關(guān)閉緩沖
  • ob_get_flush() - 刷出(送出)緩沖區(qū)內(nèi)容,以字符串形式返回內(nèi)容,并關(guān)閉輸出緩沖區(qū)。
  • ob_start() - 打開輸出控制緩沖