interface_exists

(PHP 5 >= 5.0.2, PHP 7)

interface_existsCheca se a interface foi definida

Descrição

interface_exists ( string $interface_name [, bool $autoload ] ) : bool

Verifica se uma interface foi definida.

Parâmetros

interface_name

O nome da interface.

autoload

Se deve chamar __autoload ou não por padrão

Valor Retornado

Essa função retorna true se a interface de nome interface_name já foi definida, false caso contrário.

Exemplos

Exemplo #1 Exemplo de uso de interface_exists()

<?php
// Check the interface exists before trying to use it
if (interface_exists('MyInterface')) {
    class 
MyClass implements MyInterface
    
{
        
// Methods
    
}
}

?>

Veja Também