라이브러리
[PHP] ReflectionMethod::getModifiers - 메서드 수정자를 가져옵니다.
ReflectionMethod::getModifiers
PHP의 ReflectionMethod 클래스는 클래스나 인터페이스 메서드에 대한 정보를 제공합니다. ReflectionMethod::getModifiers 메서드는 메서드의 모드(Modifiers)를 반환합니다.
모드(Modifiers)
모드는 메서드의 특성을 나타냅니다. 예를 들어, 메서드가 `public`인지, `private`인지, `static`인지 등이 모드에 해당합니다.
예제
#hostingforum.kr
php
class MyClass {
public function publicMethod() {}
private function privateMethod() {}
protected function protectedMethod() {}
static function staticMethod() {}
}
$reflectionClass = new ReflectionClass('MyClass');
$reflectionMethod = $reflectionClass->getMethod('publicMethod');
echo "publicMethod 모드: " . dechex($reflectionMethod->getModifiers()) . "
";
$reflectionMethod = $reflectionClass->getMethod('privateMethod');
echo "privateMethod 모드: " . dechex($reflectionMethod->getModifiers()) . "
";
$reflectionMethod = $reflectionClass->getMethod('protectedMethod');
echo "protectedMethod 모드: " . dechex($reflectionMethod->getModifiers()) . "
";
$reflectionMethod = $reflectionClass->getMethod('staticMethod');
echo "staticMethod 모드: " . dechex($reflectionMethod->getModifiers()) . "
";
결과
#hostingforum.kr
php
publicMethod 모드: 1
privateMethod 모드: 2
protectedMethod 모드: 4
staticMethod 모드: 8
모드 정의
* `1`: `public`
* `2`: `private`
* `4`: `protected`
* `8`: `static`
* `16`: `abstract`
* `32`: `final`
* `64`: `declare`
참고
* PHP ReflectionClass:
* PHP ReflectionMethod:
* PHP Reflection:
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.