在PHP中检查方法可见性 [英] Checking method visibility in PHP
本文介绍了在PHP中检查方法可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法检查类方法是否已被声明为私有或公开?
Is there any way of checking if a class method has been declared as private or public?
我在一个控制器上工作,其中url映射到方法
I'm working on a controller where the url is mapped to methods in the class, and I only want to trigger the methods if they are defined as public.
推荐答案
您可以使用 > 反射 扩展程序,请考虑这些:
You can use the reflection extension for that, consider these:
ReflectionMethod :: isPrivate
ReflectionMethod :: isProtected
< a href =http://php.net/reflectionmethod.ispublic =nofollow noreferrer> ReflectionMethod :: isPublic
ReflectionMethod :: isStatic
ReflectionMethod::isPrivate
ReflectionMethod::isProtected
ReflectionMethod::isPublic
ReflectionMethod::isStatic
这篇关于在PHP中检查方法可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文