简体   繁体   English

获取PHP中类方法的可观察性

[英]Get the observability of class methods in PHP

The function get_classs_methods returns all methods of a class. 函数get_classs_methods返回类的所有方法。

But, is there a function or technique to get the observability of these methods? 但是,是否有一种函数或技术可以使这些方法具有可观察性?

I want to list only the public methods. 我只想列出公共方法。

The return value from get_class_methods depends on the scope you're calling it from; get_class_methods的返回值取决于您从中调用它的范围。 if you're calling it from outside the class, you'll only get the methods that are visible from the current scope. 如果从类外部调用它,则只会得到当前作用域中可见的方法。 Calling it from a method inside the class will give you all the available methods from the class. 从类中的方法调用它会为您提供该类中所有可用的方法。

If you want more information or to query the class in a more detailed manner, you probably want to look at using reflection and the getMethods method . 如果您想了解更多信息或以更详细的方式查询类,则可能需要使用反射和getMethods方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM