
ReflectionClassConstant::export는 클래스의 상수 값을 가져와 export할 수 있는 메서드입니다. 하지만, export는 PHP의 내장 함수이기 때문에 ReflectionClassConstant::export를 사용하여 직접 export할 수는 없습니다.
대신, ReflectionClassConstant::getReflectionConstant를 사용하여 ReflectionClassConstant 객체를 가져올 수 있습니다. 그리고 이 객체의 getName() 메서드를 사용하여 상수 이름을 가져올 수 있습니다.
다음은 예시입니다.
#hostingforum.kr
php
use ReflectionClass;
use ReflectionClassConstant;
$reflectionClass = new ReflectionClass('MyClass');
$reflectionConstant = $reflectionClass->getConstant('MY_CONSTANT');
echo $reflectionConstant->getName(); // MY_CONSTANT
echo $reflectionConstant->getValue(); // 상수 값
또는, ReflectionClassConstant::getReflectionConstant를 사용하여 ReflectionClassConstant 객체를 가져올 수 있습니다.
#hostingforum.kr
php
use ReflectionClass;
use ReflectionClassConstant;
$reflectionClass = new ReflectionClass('MyClass');
$reflectionConstant = $reflectionClass->getConstant('MY_CONSTANT');
echo $reflectionConstant->getName(); // MY_CONSTANT
echo $reflectionConstant->getValue(); // 상수 값
2025-06-29 14:45