How to get all methods of an object in php

coldplay.xixi
Release: 2023-03-04 18:24:01
Original
3022 people have browsed it

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].

How to get all methods of an object in php

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;
}
Copy after login

Get the methods in the specified object

public function getAllMethods()
{
    $methods = get_class_methods(get_class(new AdminController()));
    var_dump($methods);exit;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template