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() function. This function returns an array of class names of classes defined in the current program.
Syntax
| get_declare_classes(void); |
| Parameter | |
| void | void means no parameter required |
Example
- <?php
- echo "<pre>";
- print_r(get_declared_classes());
- ?>
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 name | Required the class name |
Example
- <?php
- class vinod
- {
- function vinod()
- {
- return(true);
- }
- function myfuncA()
- {
- return(true);
- }
- function myfuncB()
- {
- return(true);
- }
- }
- $class_methods = get_class_methods('vinod');
- $class_methods = get_class_methods(new vinod());
- foreach ($class_methods as $method_name)
- {
- echo "$method_name<br>";
- }
- ?>
Returns an array of the method names specified by the class.


Sam HobbseditedPosted Feb 11, 2013, 12:38 PMEdited Feb 11, 2013, 12:39 PM
Please tell me if I am wrong, but PHP seems to be sloppy about the use of the terms define and declare. In C++ the terms are clearly defined. In C++ a class is defined once and declared zero or more times. In C++ a class must be defined to be declared (used). The PHP manual uses both "defined" and "declared" to describe what this functions does, as if the two terms are synonymous, but C++ does not use the terms synonymously.