
interface_exists() 函数检查接口是否已被定义
语法
interface_exists ( $interface_name [, $autoload] );
定义和用法
此函数检查是否已定义给定接口。
参数
| 序号 | 参数及说明 | 
|---|---|
| 1 | interface_name(必需) 接口名称 | 
| 2 | autoload(可选) 默认是否调用 __autoload。  | 
返回值
 本函数在由 interface_name 给出的接口已定义时返回 TRUE,否则返回 FALSE。 
在线示例
以下是此函数的用法-
<?php
    // 在尝试使用前先检查接口是否存在
   if (interface_exists('SomeInterface')) {
      class MyClass implements SomeInterface {
         // 方法
      }
   }
?>
                    
                