get_defined_functions

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

get_defined_functions返回所有已定義函數(shù)的數(shù)組

說明

get_defined_functions(bool $exclude_disabled = false): array

獲取所有已定義函數(shù)的數(shù)組。

參數(shù)

exclude_disabled

禁用的函數(shù)是否應(yīng)該在返回的數(shù)據(jù)里排除。

返回值

返回數(shù)組,包含了所有已定義的函數(shù),包括內(nèi)置(internal) 和用戶定義的函數(shù)。 可通過$arr["internal"]來訪問系統(tǒng)內(nèi)置函數(shù), 通過$arr["user"]來訪問用戶自定義函數(shù) (參見示例)。

更新日志

版本 說明
PHP 7.0.15, PHP 7.1.1 增加 exclude_disabled 參數(shù)。

范例

示例 #1 get_defined_functions() 例子

<?php
function myrow($id$data)
{
    return 
"<tr><th>$id</th><td>$data</td></tr>\n";
}

$arr get_defined_functions();

print_r($arr);
?>

以上例程的輸出類似于:

Array
(
    [internal] => Array
        (
            [0] => zend_version
            [1] => func_num_args
            [2] => func_get_arg
            [3] => func_get_args
            [4] => strlen
            [5] => strcmp
            [6] => strncmp
            ...
            [750] => bcscale
            [751] => bccomp
        )

    [user] => Array
        (
            [0] => myrow
        )

)

參見