无涯教程-PHP - interface_exists()函数

52 阅读1分钟

interface_exists() - 语法

interface_exists ( $interface_name [, $autoload] );

此函数检查是否定义了给定的接口。

Sr.No Parameter & Description
1

interface_name(必需)

接口名称

2

autoload(可选)

默认情况下是否调用_autoload。

interface_exists() - 返回值

如果定义了interface_name给定的接口,则返回true,否则返回false。

interface_exists() - 示例

<?php
   if (interface_exists(SomeInterface)) {
      class MyClass implements SomeInterface {
         //Methods
      }
   }
?> 

参考链接

www.learnfk.com/php/php-fun…