기타 defined
(PHP 4, PHP 5, PHP 7, PHP 8)
defined — 주어진 명명된 상수가 존재하는지 확인
설명
defined(string $constant_name
): bool
주어진 상수가 존재하고 정의되어 있는지 확인합니다.
메모: 변수가 존재하는지 확인하려면 defined() 상수에만 적용되는 isset()을 사용하십시오. 함수가 존재하는지 확인하려면 function_exists()를 사용하십시오.
매개변수
constant_name
- 상수 이름.
반환 값
constant_name
에 의해 지정된 명명된 상수가 정의되어 있으면 true
를 반환하고, 그렇지 않으면 false
를 반환합니다.
Examples
예제 #1 상수 확인하기
<?php
/* Note the use of quotes, this is important. This example is checking
* if the string 'TEST' is the name of a constant named TEST */
if (defined('TEST')) {
echo TEST;
}
?>
기타
- define() - 명명된 상수를 정의합니다.
- constant() - 상수 값을 반환합니다.
- get_defined_constants() - 모든 상수의 이름과 값이 포함된 연관 배열을 반환합니다.
- function_exists() - 주어진 함수가 정의되면 true를 반환합니다.
- Constants 섹션