
1. ReflectionMethod::__construct 메소드는 클래스의 메소드를 반영하는 ReflectionMethod 객체를 생성하는 역할을 합니다.
2. 이 메소드는 클래스 이름, 메소드 이름, 객체 이름을 파라미터로 받고, ReflectionMethod 객체를 반환합니다.
3. ReflectionMethod::__construct 메소드를 사용하는 예시입니다.
#hostingforum.kr
php
class User {
public function sayHello() {
echo "Hello!";
}
}
$user = new User();
$reflectionMethod = new ReflectionMethod($user, 'sayHello');
echo $reflectionMethod->getName(); // sayHello
echo $reflectionMethod->getDeclaringClass()->getName(); // User
이 예시에서, ReflectionMethod::__construct 메소드는 User 클래스의 sayHello 메소드를 반영하는 ReflectionMethod 객체를 생성합니다.
2025-05-01 04:13