
ReflectionFunction::__toString 메서드는 ReflectionFunction 객체의 정보를 문자열로 반환하는 메서드입니다.
예를 들어, 다음 코드를 보겠습니다.
#hostingforum.kr
php
function sayHello($name) {
return "Hello, " . $name;
}
$reflection = new ReflectionFunction('sayHello');
echo $reflection->__toString();
이 코드의 결과는 다음과 같습니다.
#hostingforum.kr
php
Reflection of: sayHello
Function [ function sayHello ]
Flags : INTEGER
Parameters : 1
Parameter #0 : $name
Type : string
Name : sayHello
File : /path/to/file.php
Line : 1
Chars : function sayHello($name) { ... }
ReflectionFunction::__toString 메서드를 사용하는 경우는 다음과 같습니다.
1. ReflectionFunction 객체의 정보를 문자열로 반환할 때 사용합니다.
2. ReflectionFunction 객체의 정보를 로깅 atau 기록할 때 사용합니다.
3. ReflectionFunction 객체의 정보를 UI에 표시할 때 사용합니다.
예를 들어, 다음 코드를 보겠습니다.
#hostingforum.kr
php
function sayHello($name) {
return "Hello, " . $name;
}
$reflection = new ReflectionFunction('sayHello');
echo "";
print_r($reflection->__toString());
echo "
";
이 코드는 ReflectionFunction 객체의 정보를 문자열로 반환하고, UI에 표시합니다.
2025-06-24 20:01