라이브러리
[PHP] ReflectionConstant::getExtensionName - 정의 확장의 이름을 가져옵니다.
ReflectionConstant::getExtensionName
PHP ReflectionConstant::getExtensionName 메소드는 클래스의 상수에 대한 확장 이름을 반환합니다.
# 사용법
ReflectionConstant::getExtensionName 메소드는 ReflectionClass 또는 ReflectionProperty의 인스턴스에 대해 호출됩니다.
# 예제
#hostingforum.kr
php
// ReflectionClass 예제
class MyClass {
const MY_CONSTANT = 'my_constant';
}
$reflectionClass = new ReflectionClass('MyClass');
$reflectionConstant = $reflectionClass->getConstant('MY_CONSTANT');
echo $reflectionConstant->getExtensionName(); // 출력: PHP
// ReflectionProperty 예제
class MyClass {
public $myProperty;
}
$reflectionClass = new ReflectionClass('MyClass');
$reflectionProperty = $reflectionClass->getProperty('myProperty');
echo $reflectionProperty->getExtensionName(); // 출력: PHP
# 설명
ReflectionConstant::getExtensionName 메소드는 클래스의 상수나 프로퍼티에 대한 확장 이름을 반환합니다. 확장 이름은 PHP 확장 이름입니다.
# 참고
- ReflectionClass: PHP ReflectionClass 클래스는 클래스의 정보를 가져올 수 있는 클래스입니다.
- ReflectionProperty: PHP ReflectionProperty 클래스는 프로퍼티의 정보를 가져올 수 있는 클래스입니다.
- ReflectionConstant: PHP ReflectionConstant 클래스는 상수의 정보를 가져올 수 있는 클래스입니다.
추가 예제
#hostingforum.kr
php
// 상수에 대한 확장 이름
class MyClass {
const MY_CONSTANT = 'my_constant';
}
$reflectionClass = new ReflectionClass('MyClass');
$reflectionConstant = $reflectionClass->getConstant('MY_CONSTANT');
echo $reflectionConstant->getExtensionName(); // 출력: PHP
// 프로퍼티에 대한 확장 이름
class MyClass {
public $myProperty;
}
$reflectionClass = new ReflectionClass('MyClass');
$reflectionProperty = $reflectionClass->getProperty('myProperty');
echo $reflectionProperty->getExtensionName(); // 출력: PHP
// 인터페이스에 대한 확장 이름
interface MyInterface {
const MY_CONSTANT = 'my_constant';
}
$reflectionClass = new ReflectionClass('MyInterface');
$reflectionConstant = $reflectionClass->getConstant('MY_CONSTANT');
echo $reflectionConstant->getExtensionName(); // 출력: PHP
마치며
ReflectionConstant::getExtensionName 메소드는 클래스의 상수나 프로퍼티에 대한 확장 이름을 반환합니다. 확장 이름은 PHP 확장 이름입니다. 이 메소드는 ReflectionClass 또는 ReflectionProperty의 인스턴스에 대해 호출됩니다.
참고 자료
- PHP Manual: ReflectionClass
- PHP Manual: ReflectionProperty
- PHP Manual: ReflectionConstant
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.