get_class_methods

Gets the class methods' names

Syntax

get_class_methods ( mixed $class_name ) : array

Parameters

class_name

The class name or an object instance

Return

Returns an array of method names defined for the class specified by class_name. In case of an error, it returns NULL.

Examples

class_name | Class Name

<?

class myclass
{
    function myfunction1()
    {
    }
    function myfunction2()
    {
    }
}

$class_name = "myclass";

$return = get_class_methods($class_name);

print_r($return);

?>
Array
(
    [0] => myfunction1
    [1] => myfunction2
)

class_name | Object Instance

<?

class myclass
{
    function myfunction1()
    {
    }
    function myfunction2()
    {
    }
}

$class_name = new myclass();

$return = get_class_methods($class_name);

print_r($return);

?>
Array
(
    [0] => myfunction1
    [1] => myfunction2
)

PHP

Home Menu