首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ReflectionMethod::getModifiers

(PHP 5, PHP 7)

ReflectionMethod :: getModifiers - 获取方法修饰符

描述

代码语言:javascript
复制
public int ReflectionMethod::getModifiers ( void )

返回此方法的访问修饰符的位域。

参数

该功能没有参数。

返回值

修饰符的数字表示。下面列出了修饰符。这些修饰符的实际含义在预定义的常量中进行了描述。

例子

示例#1 ReflectionMethod :: getModifiers()示例

代码语言:javascript
复制
<?php
class Testing
{
    final public static function foo()
    {
        return;
    }
    public function bar()
    {
        return;
    }
}

$foo = new ReflectionMethod('Testing', 'foo');

echo "Modifiers for method foo():\n";
echo $foo->getModifiers() . "\n";
echo implode(' ', Reflection::getModifierNames($foo->getModifiers())) . "\n";

$bar = new ReflectionMethod('Testing', 'bar');

echo "Modifiers for method bar():\n";
echo $bar->getModifiers() . "\n";
echo implode(' ', Reflection::getModifierNames($bar->getModifiers()));
?>

上面的例子会输出类似于:

代码语言:javascript
复制
Modifiers for method foo():
261
final public static
Modifiers for method bar():
65792
public

← ReflectionMethod::getDeclaringClass

ReflectionMethod::getPrototype →

扫码关注腾讯云开发者

领取腾讯云代金券