PHP - Function get_class_methods()


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.

Parameters

Sr.No Parameter & Description
1

class_name

Required. 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 \n";
   }
?> 

It will produce the following result −

myclass
myfunc1
myfunc2

php_function_reference.htm

Advertisements