
ReflectionProperty::getModifiers는 오버로딩된 메소드의 접근 제어자를 가져올 수 있는 메소드입니다.
예를 들어, 다음 코드를 보겠습니다.
#hostingforum.kr
php
class MyClass {
public function myMethod() {}
protected function myMethod2() {}
}
$reflectionClass = new ReflectionClass('MyClass');
$reflectionMethod1 = $reflectionClass->getMethod('myMethod');
$reflectionMethod2 = $reflectionClass->getMethod('myMethod2');
echo $reflectionMethod1->getModifiers() . "n"; // 1 (public)
echo $reflectionMethod2->getModifiers() . "n"; // 2 (protected)
ReflectionProperty::getModifiers는 메소드의 접근 제어자를 8진수 형태로 반환합니다.
- 1: public
- 2: protected
- 4: private
- 8: static
이러한 값은 메소드의 접근 제어자를 가져올 때 사용할 수 있습니다.
2025-07-11 03:30