Home > Article > Backend Development > How to get all methods of an object in php
php method to get all methods of an object: 1. Get all methods in the current object, the code is [$methods = get_class_methods(get_class())]; 2. Get the methods in the specified object, the code is [ $methods = get_class_met].
php method to get all methods of an object:
When doing background rbac permission management, I don’t want to manually add permissions , you can automatically put the methods in the current class into the menu.
Get all the methods in the current object
public function getAllMethods() { $methods = get_class_methods(get_class()); var_dump($methods);exit; }
Get the methods in the specified object
public function getAllMethods() { $methods = get_class_methods(get_class(new AdminController())); var_dump($methods);exit; }
Related learning recommendations: php programming (video )
The above is the detailed content of How to get all methods of an object in php. For more information, please follow other related articles on the PHP Chinese website!