PHP get_defined_functions() Function
The PHP get_defined_functions() function is used to get an array of all defined functions.
Syntax
get_defined_functions(exclude_disabled)
Parameters
exclude_disabled |
Optional. Specify whether the disabled functions should be excluded from the return value or not. Default is true. |
Return Value
Returns a multidimensional array containing a list of all defined functions, both built-in (internal) and user-defined. The internal functions will be accessible via $arr["internal"], and the user defined ones using $arr["user"].
Example: get_defined_functions() example
The example below shows the usage of get_defined_functions() function.
<?php function myFunction() { //codes } //getting an array of all defined functions $arr = get_defined_functions(); //displaying the result print_r($arr) ?>
The output of the above code will be similar to:
Array ( [internal] => Array ( [0] => zend_version [1] => func_num_args [2] => func_get_arg [3] => func_get_args [4] => strlen [5] => strcmp [6] => strncmp ... [1267] => opcache_is_script_cached [1268] => dl [1269] => cli_set_process_title [1270] => cli_get_process_title ) [user] => Array ( [0] => myfunction ) )
Example: getting the list of all user-defined functions
Consider one more example where this function is used to get the list of all user-defined functions.
<?php function myFunction1() { //codes } function myFunction2() { //codes } function myFunction3() { //codes } //getting an array of all defined functions $arr = get_defined_functions(); //displaying the list of //all user-defined functions print_r($arr["user"]) ?>
The output of the above code will be:
Array ( [0] => myfunction1 [1] => myfunction2 [2] => myfunction3 )
❮ PHP Function Handling Reference