
ReflectionProperty 클래스의 __toString 메서드는 해당 프로퍼티의 이름을 문자열로 반환합니다.
예를 들어, 다음 코드를 살펴보겠습니다.
#hostingforum.kr
php
$reflectionClass = new ReflectionClass('stdClass');
$reflectionProperty = $reflectionClass->getProperty('name');
echo $reflectionProperty->__toString(); // Output: name
이 코드에서는 stdClass 클래스의 name 프로퍼티에 대한 ReflectionProperty 객체를 생성하고, __toString 메서드를 호출하여 프로퍼티 이름을 문자열로 반환합니다.
이 메서드는 프로퍼티의 이름을 문자열로 반환하는 데 사용할 수 있습니다.
2025-05-04 03:42