(PHP 5, PHP 7, PHP 8)
ReflectionMethod::getModifiers — 取得方法修飾符
此函式沒有參數。
修飾符的數字表示。這些修飾符的實際意義在預定義常數下有說明。
範例 #1 ReflectionMethod::getModifiers() 範例
<?php
class Testing
{
final public static function foo()
{
return;
}
public function bar()
{
return;
}
}
$foo = new ReflectionMethod('Testing', 'foo');
echo "方法 foo() 的修飾詞:\n";
echo $foo->getModifiers() . "\n";
echo implode(' ', Reflection::getModifierNames($foo->getModifiers())) . "\n";
$bar = new ReflectionMethod('Testing', 'bar');
echo "方法 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