Class and Object Function in PHP – Info PHP

Introduction

 

In this article I will discuss the “get_declare_classes()” and “get_class_method()” functions in PHP. These functions are for classes and objects in PHP.

 

First of all I am using the get_declare_classes() . This function returns an array of names of classes defined in the current program.

 

Syntax

 

get_declare_classes(void);

 

Parameter
voidvoid means no parameter required

 

Example

  1. echo 
    "

    ;  

  2. print_r(get_declared_classes());  
  3. ?>  

Returns an array of the class names of the defined classes in this code.

 

Output

 

 

This function either returns an array of the method names of the specified class names or returns the errors. 

 

Syntax

 

get_class_method($class_name);

 

Parameter
class nameRequired the class name

 

Example

  1. class vinod  
  2. {  
  3.         function vinod()  
  4.     {  
  5.         return(true);  
  6.     }  
  7.     function myfuncA()  
  8.     {  
  9.         return(true);  
  10.     }  
  11.     function myfuncB()  
  12.     {  
  13.         return(true);  
  14.     }  
  15. }  
  16. $class_methods = get_class_methods(‘vinod’);  
  17. $class_methods = get_class_methods(new vinod());  
  18.    
  19. foreach ($class_methods as $method_name)  
  20. {  
  21.     echo “$method_name
    ;  
  22. }  
  23.    
  24. ?>  

Returns an array of the method names specified by the class.

 

get class method function in php.jpg

Article Prepared by Ollala Corp

You might also like
Leave A Reply

Your email address will not be published.