Wednesday, June 17, 2026
HomeLanguagesPHP | Reflection getModifierNames() Function

PHP | Reflection getModifierNames() Function

The Reflection::getModifierNames() function is an inbuilt function in PHP which is used to return an array of the specified modifier names.
 

Syntax:  

array Reflection::getModifierNames( int $modifiers )

Parameters: This function accepts single parameter $modifiers which is Bitfield of the modifiers. Here the bitfield is a data structure consisting of a number of adjacent computer memory locations.
Return Value: This function returns an array of the specified modifier names.
Below programs illustrate the Reflection::getModifierNames() function in PHP: 
Program 1:  

php




<?php
 
// Declaring a class Testing
class Testing
{
     
    // Calling a function neveropen() with
    // two modifier named as public and static
    public static function neveropen()
    {
        return;
    }
}
 
// ReflectionMethod is called on the class Testing and
// their member as function neveropen()
$neveropen = new ReflectionMethod('Testing', 'neveropen');
 
// Calling the getModifierNames() function and printing
// an array of modifier names
echo implode(' ', Reflection::getModifierNames($neveropen->getModifiers()));
?>


Output: 

public static

 

Program 2: 

php




<?php
 
// Declaring a class Testing
class Testing
{
     
    // Calling a function GFG() with
    // two modifier named as public and static
    final public function GFG()
    {
        return;
    }
}
 
// ReflectionMethod is called on the class Testing and
// their member as function GFG()
$GFG = new ReflectionMethod('Testing', 'GFG');
 
// Calling the getModifierNames() function and printing
// an array of modifier names
echo implode(' ', Reflection::getModifierNames($GFG->getModifiers()));
?>


Output: 

final public

 

Reference: https://www.php.net/manual/en/reflection.getmodifiernames.php

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6898 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS