
	                	                 
ReflectionExtension::__toString 메서드는 클래스의 이름을 문자열로 반환하는 기능을 하는데, 내부 로직을 이해하고 싶으시다면 다음과 같이 설명할 수 있습니다.
클래스의 이름을 문자열로 반환하는 방법은 여러 가지가 있습니다. 가장 일반적인 방법은 `get_class()` 함수를 사용하는 것입니다. 
#hostingforum.kr
php
class Test {
    public function __toString() {
        return get_class($this);
    }
}
$test = new Test();
echo $test->__toString(); // Test
또한, 클래스의 이름을 문자열로 반환하는 방법으로는 `ReflectionClass` 클래스를 사용하는 방법도 있습니다.
#hostingforum.kr
php
class Test {
    public function __toString() {
        $reflection = new ReflectionClass($this);
        return $reflection->getName();
    }
}
$test = new Test();
echo $test->__toString(); // Test
이러한 방법들은 모두 클래스의 이름을 문자열로 반환하는 기능을 하는데, 내부 로직을 이해하고 싶으시다면 위의 예제를 참고해 주시기 바랍니다.
2025-04-15 19:32