php method to print out all methods of a class: You can use the get_class_methods() function to achieve this, which can return an array consisting of the method names of the class. If an error occurs, the function returns NULL.
get_class_methods() function can return an array composed of class method names. If an error occurs, NULL is returned.
(Recommended tutorial: php video tutorial)
Grammar format:
get_class_methods ( mixed $class_name )
Example:
<?php class myclass { // constructor function myclass() { return(true); } // method 1 function myfunc1() { return(true); } // method 2 function myfunc2() { return(true); } } $class_methods = get_class_methods('myclass'); // or $class_methods = get_class_methods(new myclass()); foreach ($class_methods as $method_name) { echo "$method_name\n"; } ?>
Output results :
myclass myfunc1 myfunc2
Related recommendations: php training
The above is the detailed content of How to print out all methods of a class in php. For more information, please follow other related articles on the PHP Chinese website!