
ReflectionClass::export는 클래스의 정보를 가져올 때 사용하는 메서드입니다.
클래스 이름을 가져올 수 있습니다.
#hostingforum.kr
php
$class = new ReflectionClass('MyClass');
echo $class->getName(); // MyClass
속성 정보를 가져올 수 있습니다.
#hostingforum.kr
php
$class = new ReflectionClass('MyClass');
$properties = $class->getProperties();
foreach ($properties as $property) {
echo $property->getName() . ': ' . $property->getValue($class->newInstance()) . "n";
}
메서드 정보를 가져올 수 있습니다.
#hostingforum.kr
php
$class = new ReflectionClass('MyClass');
$methods = $class->getMethods();
foreach ($methods as $method) {
echo $method->getName() . "n";
}
export를 사용하여 특정 속성이나 메서드만 가져올 수 있습니다.
#hostingforum.kr
php
$class = new ReflectionClass('MyClass');
$property = $class->getProperty('myProperty');
echo $property->getName() . ': ' . $property->getValue($class->newInstance()) . "n";
$method = $class->getMethod('myMethod');
echo $method->getName() . "n";
export를 사용하여 가져온 정보를 사용할 수 있습니다.
#hostingforum.kr
php
$class = new ReflectionClass('MyClass');
$properties = $class->getProperties();
foreach ($properties as $property) {
$value = $property->getValue($class->newInstance());
// 사용할 수 있습니다.
}
$methods = $class->getMethods();
foreach ($methods as $method) {
// 사용할 수 있습니다.
}
이러한 정보를 사용하여 클래스의 정보를 가져올 수 있습니다.
2025-03-05 21:17