라이브러리

[PHP] ReflectionClass::getDocComment - 문서 주석 가져오기




ReflectionClass::getDocComment

PHP ReflectionClass::getDocComment 메소드는 클래스의 문서 주석을 반환합니다. 문서 주석은 클래스의 설명을 포함하는 주석으로, 클래스의 생성자, 메소드, 속성에 적용할 수 있습니다.

문서 주석의 구조

문서 주석은 다음과 같은 구조를 가집니다.

#hostingforum.kr
php

/

 * 클래스 설명

 *

 * @property string $속성 설명

 * @method string 메소드 설명

 */



예제

다음 예제는 ReflectionClass::getDocComment 메소드를 사용하여 클래스의 문서 주석을 가져오는 방법을 보여줍니다.

#hostingforum.kr
php

// 클래스 문서 주석

class User {

    

     * 사용자 정보를 저장하는 클래스입니다.

     *

     * @property string $name 이름

     * @property string $email 이메일

     * @method string getName 이름을 반환합니다.

     * @method string getEmail 이메일을 반환합니다.

     */

    private $name;

    private $email;



    public function __construct($name, $email) {

        $this->name = $name;

        $this->email = $email;

    }



    public function getName() {

        return $this->name;

    }



    public function getEmail() {

        return $this->email;

    }

}



// ReflectionClass::getDocComment 메소드를 사용하여 클래스의 문서 주석을 가져옵니다.

$reflectionClass = new ReflectionClass('User');

$docComment = $reflectionClass->getDocComment();



echo $docComment;



출력

#hostingforum.kr


/

 * 사용자 정보를 저장하는 클래스입니다.

 *

 * @property string $name 이름

 * @property string $email 이메일

 * @method string getName 이름을 반환합니다.

 * @method string getEmail 이메일을 반환합니다.

 */



결론**

ReflectionClass::getDocComment 메소드는 클래스의 문서 주석을 반환합니다. 문서 주석은 클래스의 설명을 포함하는 주석으로, 클래스의 생성자, 메소드, 속성에 적용할 수 있습니다. 이 메소드를 사용하여 클래스의 문서 주석을 가져올 수 있습니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 10,077건 / 291 페이지

검색

게시물 검색