Home  >  Article  >  Backend Development  >  How to get all methods of an object in php

How to get all methods of an object in php

coldplay.xixi
coldplay.xixiOriginal
2020-08-19 09:37:262940browse

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;
}

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!

Statement:
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