
ReflectionParameter 클래스의 __toString() 메서드는 객체의 정보를 문자열로 반환합니다.
이 메서드를 사용할 때는 매개변수를 지정하지 않으면 모든 객체의 정보가 반환됩니다.
매개변수를 지정하려면 ReflectionParameter 클래스의 getName() 메서드를 사용하여 매개변수의 이름을 얻은 후, ReflectionParameter 클래스의 __toString() 메서드에 매개변수의 이름을 전달하면 됩니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$reflectionParameter = new ReflectionParameter('MyClass', 'myMethod');
echo $reflectionParameter->getName(); // myMethod
echo $reflectionParameter->__toString(); // myMethod
또는, 매개변수의 이름을 직접 전달할 수도 있습니다.
#hostingforum.kr
php
echo $reflectionParameter->__toString('myMethod'); // myMethod
이러한 방법으로, ReflectionParameter 클래스의 __toString() 메서드를 사용하여 특정 매개변수의 정보만을 반환할 수 있습니다.
2025-03-18 23:40