
ReflectionReference::__construct 메소드는 두 개의 파라미터를 받습니다.
1. $object: 클래스의 인스턴스
2. $property: 클래스의 프로퍼티 이름
이 메소드는 클래스의 프로퍼티를 참조하기 위해 사용됩니다.
예를 들어, 다음 코드를 살펴보겠습니다.
#hostingforum.kr
php
class MyClass {
public $myProperty;
}
$obj = new MyClass();
$obj->myProperty = 'Hello, World!';
$reflection = new ReflectionClass($obj);
$property = $reflection->getProperty('myProperty');
$reflectionReference = new ReflectionReference($obj, 'myProperty');
echo $reflectionReference->getValue(); // Hello, World!
위 코드에서, ReflectionReference::__construct 메소드는 $obj 인스턴스와 'myProperty' 프로퍼티 이름을 파라미터로 받습니다.
이후, getValue 메소드를 호출하여 프로퍼티의 값을 가져올 수 있습니다.
2025-03-30 21:18