ReflectionMethod::getModifiers
(PHP 5, PHP 7, PHP 8)
ReflectionMethod::getModifiers — 获取方法的修饰符
说明
public ReflectionMethod::getModifiers(): int
返回一个方法的修饰符,返回值是一个位标
参数
此函数没有参数。
返回值
使用一个数字表示方法修饰符,具体数字的含义可以参考 predefined constants 中的说明。
范例
示例 #1 ReflectionMethod::getModifiers() example
<?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()));
?>
以上例程的输出类似于:
Modifiers for method foo(): 261 final public static Modifiers for method bar(): 65792 public

User Contributed Notes
There are no user contributed notes for this page.
备份地址:http://www.lvesu.com/blog/php/reflectionmethod.getmodifiers.php