PHP - Function get_class_methods()


Advertisements


Syntax

get_method ( $class_name );

Definition and Usage

It 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

It 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 HelloWorld {
      function HelloWorld() {
         return(true);
      }
      
      function myfunc1() {
         return(true);
      }
      
      function myfunc2() {
         return(true);
      }
   }
	
   $method = get_method('HelloWorld');
   $method = get_method(new HelloWorld());
   
   foreach ($method as $method_name) {
      echo "$method_name \n";
   }
?> 

It will produce the following result −

HelloWorld
myfunc1
myfunc2

php_function_reference.htm

Advertisements