English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP tutorial

Advanced PHP tutorial

PHP & MySQL

PHP reference manual

PHP get_class_methods() function usage and example

PHP Class/Object function reference manual

The get_class_methods() function returns an array composed of class method names

Syntax

get_class_methods($class_name);

Definition and Usage

It retrieves the class method names. Returns an array of method names defined by class_name. If an error occurs, it returns NULL.

Parameter

NumberParameters and Description
1

class_name(Required)

Class name.

Return value

 Returns an array of method names defined in the class specified by class_name. If an error occurs, it returns NULL.

Online Example

The following is the usage of this function, to get the method names of HelloWorld class-

<?php
   class HelloWorld {
      function HelloWorld() {
         return(true);
      }
      
      function myfunc1() {
         return(true);
      }
      
      function myfunc2() {
         return(true);
      }
   }
   $method = get_class_methods('HelloWorld');
   $method = get_class_methods(new HelloWorld());
   
   foreach ($method as $method_name) {
      echo "$method_name \n";
   }
?>
Test to see ‹/›

It will produce the following result-

HelloWorld
myfunc1
myfunc2

  PHP Class/Object function reference manual