
__toString() 함수는 ReflectionConstant 클래스에서 상속된 함수로, 객체를 문자열로 표현하는 역할을 합니다.
이 함수는 ReflectionConstant 객체의 이름을 반환합니다. 예를 들어, ReflectionClass::getName() 함수도 ReflectionConstant 클래스에서 상속된 함수로, 클래스 이름을 반환합니다.
예를 들어, 다음과 같은 코드를 작성할 수 있습니다.
#hostingforum.kr
php
$reflectionClass = new ReflectionClass('MyClass');
echo $reflectionClass->getName(); // MyClass
$reflectionConstant = new ReflectionClass('MY_CONSTANT');
echo $reflectionConstant->__toString(); // MY_CONSTANT
이 예제에서, ReflectionClass::getName() 함수는 클래스 이름을 반환하고, ReflectionConstant::__toString() 함수는 상수 이름을 반환합니다.
2025-03-17 19:32