PHP 8.5.8 Released!

ReflectionMethod::getModifiers

(PHP 5, PHP 7, PHP 8)

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

说明

public function ReflectionMethod::getModifiers(): int

返回一个方法的修饰符,返回值是一个位标。

参数

此函数没有参数。

返回值

使用数字表示方法修饰符。这些修饰符的实际含义可以参考预定义常量中的说明。

示例

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

<?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():
49
final public static
Modifiers for method bar():
1
public

参见

发现了问题?

了解如何改进此页面提交拉取请求报告一个错误
+添加备注

用户贡献的备注

此页面尚无用户贡献的备注。

AltStyle によって変換されたページ (->オリジナル) /