Reflection ReflectionClass::hasConstant

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

ReflectionClass::hasConstant — 상수가 정의되었는지 확인


설명

public ReflectionClass::hasConstant(string $name): bool

클래스에 정의된 특정 상수가 있는지 여부를 확인합니다.


매개변수

name
확인 중인 상수의 이름입니다.

반환 값

상수가 정의되어 있으면 true이고, 그렇지 않으면 false입니다.


Examples

예제 #1 ReflectionClass::hasConstant() 예제

                  
<?php
class Foo {
    const c1 = 1;
}

$class = new ReflectionClass("Foo");

var_dump($class->hasConstant("c1"));
var_dump($class->hasConstant("c2"));
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

bool(true)
bool(false)
                

기타