Sunday, November 23, 2025
HomeLanguagesPHP get_defined_functions() Function

PHP get_defined_functions() Function

The get_defined_functions() function is an inbuilt function in PHP which returns the all defined functions in the array format.

Syntax:

array get_defined_functions( bool $exclude_disabled = true )

Parameters: This function accepts one parameter that is described below:

  • $exclude_disabled: It will check whether the disabled functions will be excluded from the return value i.e. if the function is false, it returns a value otherwise it will return the full definition of the function.

Return value: The return value will be a multidimensional array that has the list of all defined functions(ie., both built-in and user-defined). This function returns a definition of the function or returns the value of the function if the parameter will be true.

Example 1: In this example, we demonstrated the get_defined_functions() function.

PHP




<?php
    function hello_world(){
        echo "neveropen";
    }
    $arr = get_defined_functions();
        
    print_r($arr);
?>


Output:

Array
(
   [internal] => Array
       (
           [0] => zend_version
           [1] => func_num_args
           [2] => func_get_arg
           [3] => func_get_args
           [4] => strlen
           [5] => strcmp
           [6] => strncmp
           [7] => strcasecmp
           [8] => strncasecmp
           [9] => error_reporting
           [10] => define
           [11] => defined
}     [user] => Array
       (
           [0] => hello_world
       ) )
 

Example 2: In this example, we will print only user-defined functions in an array form.

PHP




<?php
    function hello_world(){
        echo "neveropen";
    }
    function bye_gfg(){
        echo "Bye neveropen" ;
    }
    $arr = get_defined_functions();
        
    print_r($arr["user"]);
?>


Output:

Array
(
   [0] => hello_world
   [1] => bye_gfg
)

Reference: https://www.php.net/manual/en/function.get-defined-functions.php

RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6864 POSTS0 COMMENTS
Umr Jansen
6852 POSTS0 COMMENTS