
ReflectionConstant::getValue 메서드는 ReflectionConstant 클래스의 정적 메서드입니다. 이 메서드는 클래스의 상수 필드의 값을 반환하는 역할을 합니다.
getValue 메서드를 호출할 때, 필드 이름을 파라미터로 전달해야 합니다. 예를 들어, ReflectionConstant 클래스에 상수 필드가 'MY_CONSTANT'이라면, getValue 메서드를 호출할 때 'MY_CONSTANT'을 파라미터로 전달하면 됩니다.
예시 코드는 다음과 같습니다.
#hostingforum.kr
php
class ReflectionConstant {
public const MY_CONSTANT = 'Hello, World!';
}
$reflectionClass = new ReflectionClass(ReflectionConstant::class);
$constantValue = $reflectionClass->getConstant('MY_CONSTANT');
echo $constantValue; // Hello, World!
위 코드에서, ReflectionClass::getConstant 메서드를 사용하여 상수 필드의 값을 가져옵니다. ReflectionConstant::getValue 메서드는 ReflectionClass::getConstant 메서드와 동일한 역할을 합니다.
2025-07-30 14:32