Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function get_class_methods()


previous

Advertisements

Syntax

get_class_methods ( $class_name );

Definition and Usage

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

Paramters

ParameterDescription
class_nameRequired. The class name.

Return Value

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

Example

Following is the usage of this function:

<?php
class myclass {
    // constructor
    function myclass()
    {
        return(true);
    }
    function myfunc1()
    {
        return(true);
    }
    function myfunc2()
    {
        return(true);
    }
}
$class_methods = get_class_methods('myclass');
$class_methods = get_class_methods(new myclass());

foreach ($class_methods as $method_name) {
    echo "$method_name<br>";
}

?> 

It will produce following result:

myclass
myfunc1
myfunc2

previous Printer Friendly

Advertisements


  

Advertisements