interface_exists

(PHP 5 >= 5.0.2, PHP 7)

interface_exists锟斤拷锟接匡拷锟角凤拷锟窖憋拷锟斤拷锟斤拷

说锟斤拷

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

锟斤拷锟接匡拷锟角凤拷锟窖憋拷锟斤拷锟藉。

锟斤拷锟斤拷

interface_name

锟接匡拷锟斤拷锟斤拷

autoload

默锟斤拷锟角凤拷锟斤拷锟� __autoload锟斤拷

锟斤拷锟斤拷值

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 interface_name 锟斤拷锟斤拷锟侥接匡拷锟窖讹拷锟斤拷时锟斤拷锟斤拷 TRUE锟斤拷锟斤拷锟津返伙拷 FALSE锟斤拷

锟斤拷锟斤拷

Example #1 interface_exists() 锟斤拷锟斤拷

<?php
// 锟节筹拷锟斤拷使锟斤拷前锟饺硷拷锟接匡拷锟角凤拷锟斤拷锟�
if (interface_exists('MyInterface')) {
    class 
MyClass implements MyInterface
    
{
        
// Methods
    
}
}

?>

锟轿硷拷

  • get_declared_interfaces() - 锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷慕涌锟�
  • class_implements() - 锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷实锟街碉拷锟斤拷锟叫接口★拷
  • class_exists() - 锟斤拷锟斤拷锟斤拷欠锟斤拷讯锟斤拷锟�