Saturday, October 11, 2025
HomeLanguagesPHP | ReflectionMethod getModifiers() Function

PHP | ReflectionMethod getModifiers() Function

The ReflectionMethod::getModifiers() function is an inbuilt function in PHP which is used to return the numeric representation of the method modifiers.

Syntax:

int ReflectionMethod::getModifiers( void )

Parameters: This function does not accept any parameter.

Return Value: This function returns the numeric representation of the method modifiers.

Below programs illustrate the ReflectionMethod::getModifiers() function in PHP:
Program_1:




<?php
  
// Initializing a user-defined class
class Company {
  
    protected function neveropen($name) {
        return 'GFG' . $name;
    }
}
  
// Using ReflectionMethod() over the class Company
$A = new ReflectionMethod(new Company(), 'neveropen');
  
// Calling the getModifiers() function
$B = $A->getModifiers();
  
// Getting the numeric representation 
// of the method modifiers.
var_dump($B);
?>


Output:

int(134283776)

Program_2:




<?php
  
// Initializing a user-defined class
class Department
{
    final public static function Coding()
    {
        return;
    }
    public function Marketing()
    {
        return;
    }
}
  
// Using ReflectionMethod() over the above class
$A = new ReflectionMethod('Department', 'Coding');
$B = new ReflectionMethod('Department', 'Marketing');
  
// Calling the getModifiers() function and 
// getting the numeric representation 
// of the above method modifiers.
var_dump($A->getModifiers());
var_dump($B->getModifiers());
?>


Output:

int(134217989)
int(134283520)

Reference: https://www.php.net/manual/en/reflectionmethod.getmodifiers.php

RELATED ARTICLES

Most Popular

Dominic
32351 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6720 POSTS0 COMMENTS
Nicole Veronica
11882 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6839 POSTS0 COMMENTS
Ted Musemwa
7102 POSTS0 COMMENTS
Thapelo Manthata
6794 POSTS0 COMMENTS
Umr Jansen
6794 POSTS0 COMMENTS