ReflectionMethod::getModifiers

(PHP 5, PHP 7)
Gets the method modifiers
public int ReflectionMethod::getModifiers ( void )

Returns a bitfield of the access modifiers for this method.

Returns:

A numeric representation of the modifiers. The modifiers are listed below. The actual meanings of these modifiers are described in the predefined constants.

Examples:
ReflectionMethod::getModifiers() example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?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()));
?>

The above example will output something similar to:

Modifiers for method foo():
261
final public static
Modifiers for method bar():
65792
public
See also:

Reflection::getModifierNames() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.