클래스/객체 interface_exists
(PHP 5 >= 5.0.2, PHP 7, PHP 8)
interface_exists — 인터페이스가 정의되었는지 확인
설명
interface_exists(string $interface
, bool $autoload
= true
): bool
지정된 인터페이스가 정의되었는지 확인합니다.
매개변수
interface
- 인터페이스 이름
autoload
- 기본적으로 __autoload를 호출할지 여부입니다.
반환 값
interface
에서 제공한 인터페이스가 정의되어 있으면 true
를 반환하고, 그렇지 않으면 false
를 반환합니다.
Examples
예제 #1 interface_exists() 예제
<?php
// Check the interface exists before trying to use it
if (interface_exists('MyInterface')) {
class MyClass implements MyInterface
{
// Methods
}
}
?>
기타
- get_declared_interfaces() - 선언된 모든 인터페이스의 배열을 반환합니다.
- class_implements() - 주어진 클래스 또는 인터페이스에 의해 구현된 인터페이스를 반환합니다.
- class_exists() - 클래스가 정의되었는지 확인
- enum_exists() - enum이 정의되었는지 확인