라이브러리
[PHP] Reflection::export - 내보내기
Reflection::export
PHP Reflection API는 PHP 코드를 분석하고, 정보를 얻기 위한 도구입니다. Reflection::export는 Reflection 객체를 문자열로 변환하여 반환하는 메소드입니다. 이 메소드는 Reflection 객체의 정보를 문자열로 출력할 때 사용됩니다.
# 사용 예제
#hostingforum.kr
php
// ReflectionClass를 사용하여 클래스 정보를 얻어옵니다.
$reflectionClass = new ReflectionClass('stdClass');
// ReflectionClass의 정보를 문자열로 출력합니다.
echo Reflection::export($reflectionClass);
위의 예제에서는 `stdClass` 클래스의 정보를 얻어와 출력합니다. 출력 결과는 다음과 같습니다.
#hostingforum.kr
php
Class [ class stdClass ] {
- Properties [ 0 ] {
}
- Methods [ 0 ] {
}
}
# 사용 예제 (메소드 정보 출력)
#hostingforum.kr
php
// ReflectionMethod를 사용하여 메소드 정보를 얻어옵니다.
$reflectionMethod = new ReflectionMethod('stdClass', 'stdClass');
// ReflectionMethod의 정보를 문자열로 출력합니다.
echo Reflection::export($reflectionMethod);
위의 예제에서는 `stdClass` 클래스의 `stdClass` 메소드의 정보를 얻어와 출력합니다. 출력 결과는 다음과 같습니다.
#hostingforum.kr
php
Method [ public method stdClass ] {
- Parameters [ 0 ] {
}
- Flags [ 0x00000000 ]
- Modifier flags [ 0x00000000 ]
- Method parameters [ 0 ]
- Returntype [ unknown ]
- Changelog [ ]
- Source Context [ ]
- Original Reflection [ ReflectionMethod Object ]
}
# 사용 예제 (프로퍼티 정보 출력)
#hostingforum.kr
php
// ReflectionProperty를 사용하여 프로퍼티 정보를 얻어옵니다.
$reflectionProperty = new ReflectionProperty('stdClass', 'stdClass');
// ReflectionProperty의 정보를 문자열로 출력합니다.
echo Reflection::export($reflectionProperty);
위의 예제에서는 `stdClass` 클래스의 `stdClass` 프로퍼티의 정보를 얻어와 출력합니다. 출력 결과는 다음과 같습니다.
#hostingforum.kr
php
Property [ public property stdClass ] {
- Type [ unknown ]
- Flags [ 0x00000001 ]
- Default [ ]
- Doc comment [ ]
- Original Reflection [ ReflectionProperty Object ]
}
# 사용 예제 (인터페이스 정보 출력)
#hostingforum.kr
php
// ReflectionClass를 사용하여 인터페이스 정보를 얻어옵니다.
$reflectionClass = new ReflectionClass('ArrayAccess');
// ReflectionClass의 정보를 문자열로 출력합니다.
echo Reflection::export($reflectionClass);
위의 예제에서는 `ArrayAccess` 인터페이스의 정보를 얻어와 출력합니다. 출력 결과는 다음과 같습니다.
#hostingforum.kr
php
Interface [ ArrayAccess ] {
- Constants [ 0 ] {
}
- Methods [ 3 ] {
Method [ public method offsetGet ] {
- Parameters [ 1 ] {
Parameter #0 [ $offset ]
}
- Flags [ 0x00000000 ]
- Modifier flags [ 0x00000000 ]
- Method parameters [ 1 ]
- Returntype [ mixed ]
- Changelog [ ]
- Source Context [ ]
- Original Reflection [ ReflectionMethod Object ]
}
Method [ public method offsetSet ] {
- Parameters [ 2 ] {
Parameter #0 [ $offset ]
Parameter #1 [ $value ]
}
- Flags [ 0x00000000 ]
- Modifier flags [ 0x00000000 ]
- Method parameters [ 2 ]
- Returntype [ void ]
- Changelog [ ]
- Source Context [ ]
- Original Reflection [ ReflectionMethod Object ]
}
Method [ public method offsetUnset ] {
- Parameters [ 1 ] {
Parameter #0 [ $offset ]
}
- Flags [ 0x00000000 ]
- Modifier flags [ 0x00000000 ]
- Method parameters [ 1 ]
- Returntype [ void ]
- Changelog [ ]
- Source Context [ ]
- Original Reflection [ ReflectionMethod Object ]
}
}
- Properties [ 0 ] {
}
}
위의 예제에서는 `ArrayAccess` 인터페이스의 정보를 얻어와 출력합니다. 출력 결과는 인터페이스의 메소드, 프로퍼티 정보를 포함합니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.