
ReflectionClassConstant::getModifiers는 클래스 상수에 적용된 접근 제어자의 비트 마스크를 반환합니다. 비트 마스크는 4개의 비트로 구성되며, 각 비트는 다음과 같은 의미를 가집니다.
- 0x01: public 접근 제어자
- 0x02: protected 접근 제어자
- 0x04: private 접근 제어자
- 0x08: static 접근 제어자
예를 들어, public static 상수는 다음과 같이 반환될 것입니다.
#hostingforum.kr
php
$modifiers = ReflectionClassConstant::getModifiers('클래스명::상수명');
echo ($modifiers & 0x01) && ($modifiers & 0x04) ? 'public static' : '';
위 코드는 ReflectionClassConstant::getModifiers가 반환하는 비트 마스크와 0x01과 0x04의 비트를 AND 연산을 통해 수행한 결과를 출력합니다. 만약 결과가 true라면 public static를 출력합니다.
2025-04-19 22:36