라이브러리
[PHP] ReflectionProperty::getDocComment - 속성 문서 주석을 가져옵니다.
ReflectionProperty::getDocComment
PHP의 ReflectionProperty 클래스는 클래스, 인터페이스, 함수, 메소드, 속성 등에 대한 정보를 제공하는 데 사용됩니다. ReflectionProperty::getDocComment 메소드는 속성에 대한 문서 주석을 반환합니다.
# 사용법
ReflectionProperty::getDocComment 메소드는 속성에 대한 문서 주석을 문자열로 반환합니다. 이 메소드는 속성이 존재하지 않거나 문서 주석이 없는 경우 NULL을 반환합니다.
# 예제
#hostingforum.kr
php
class User {
/
* @var string
*/
public $name;
* @var int
*/
public $age;
public function __construct() {
$this->name = 'John Doe';
$this->age = 30;
}
}
$user = new User();
$reflectionClass = new ReflectionClass('User');
$reflectionProperty = $reflectionClass->getProperty('name');
echo $reflectionProperty->getDocComment(); // @var string
echo "
";
$reflectionProperty = $reflectionClass->getProperty('age');
echo $reflectionProperty->getDocComment(); // @var int
echo "
";
$reflectionProperty = $reflectionClass->getProperty('nonExistentProperty');
var_dump($reflectionProperty->getDocComment()); // NULL
# 결과
#hostingforum.kr
@var string
@var int
NULL
# 참고
- ReflectionProperty::getDocComment 메소드는 속성에 대한 문서 주석을 반환합니다.
- 속성이 존재하지 않거나 문서 주석이 없는 경우 NULL을 반환합니다.
- 이 메소드는 속성의 문서 주석을 문자열로 반환합니다.
- 속성의 문서 주석을 확인하고 싶은 경우 이 메소드를 사용할 수 있습니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.