클래스/객체 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
    }
}

?>
                  
                

기타