试图理解php中的getModifiers()
以上代码取自php手册中的示例#1试图理解php中的getModifiers(),php,Php,以上代码取自php手册中的示例#1ReflectionMethod::getModifiers()示例: 问题: 代码:$foo->getModifiers(),输出是261,这是什么意思?它是一个位字段,由按位或的组成 让它更容易理解: <?php class Testing { final public static function foo() { return; } public function bar() {
ReflectionMethod::getModifiers()
示例:
问题:
代码:
$foo->getModifiers()
,输出是261,这是什么意思?它是一个位字段,由按位或的组成
让它更容易理解:
<?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()));
?>
php> =Reflection::getModifierNames(261)
array(
0 => "final",
1 => "public",
2 => "static",
)