라이브러리

[PHP] ReflectionConstant::getFileName - 정의 파일의 이름을 가져옵니다.




ReflectionConstant::getFileName

PHP ReflectionClass와 ReflectionMethod, ReflectionFunction의 하위 클래스인 ReflectionConstant는 PHP의 Reflection API를 사용하여 클래스, 메서드, 함수, 상수 등에 대한 정보를 얻는 데 사용됩니다. ReflectionConstant는 상수에 대한 정보를 제공하는 데 사용됩니다.

`getFileName()` 메서드는 상수에 대한 파일 이름을 반환합니다. 이 메서드는 상수가 정의된 파일의 이름을 반환합니다.

예제


#hostingforum.kr
php

// 상수 정의

class MyClass {

    const MY_CONSTANT = 'Hello, World!';

}



// ReflectionConstant를 사용하여 상수에 대한 정보를 얻기

$reflectionConstant = new ReflectionClass('MyClass');

$constant = $reflectionConstant->getConstant('MY_CONSTANT');



// 상수에 대한 파일 이름을 얻기

$fileName = $reflectionConstant->getFileName();



echo "상수 이름: $constant
";

echo "상수 파일 이름: $fileName
";



이 예제에서는 `MyClass` 클래스에 `MY_CONSTANT` 상수가 정의되어 있습니다. `ReflectionClass`를 사용하여 `MyClass` 클래스에 대한 정보를 얻고, `getConstant()` 메서드를 사용하여 `MY_CONSTANT` 상수를 얻습니다. `getFileName()` 메서드를 사용하여 상수에 대한 파일 이름을 얻습니다.

결과


#hostingforum.kr


상수 이름: Hello, World!

상수 파일 이름: /path/to/MyClass.php



참고


* PHP Reflection API:
* ReflectionConstant:
* ReflectionClass:
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

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

검색

게시물 검색