
ReflectionClass::getConstructor 메소드는 ReflectionMethod 인스턴스를 반환합니다.
이 메소드를 사용하여 생성자 메소드를 호출하려면 newInstanceArgs 메소드를 사용하여 인스턴스를 생성해야 합니다.
예를 들어, 다음 코드는 다음과 같이 작성할 수 있습니다.
#hostingforum.kr
php
$reflectionClass = new ReflectionClass('MyClass');
$constructor = $reflectionClass->getConstructor();
$reflectionClass->newInstanceArgs($args);
또는
#hostingforum.kr
php
$reflectionClass = new ReflectionClass('MyClass');
$constructor = $reflectionClass->getConstructor();
$reflectionClass->newInstance($arg1, $arg2, ...);
또는
#hostingforum.kr
php
$reflectionClass = new ReflectionClass('MyClass');
$constructor = $reflectionClass->getConstructor();
$instance = $reflectionClass->newInstanceWithoutConstructor();
$constructor->invokeArgs($instance, $args);
이러한 방법 중 하나를 사용하여 생성자 메소드를 호출할 수 있습니다.
2025-05-20 14:36