array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.interface-exists.php', 1 => 'interface_exists', ), 'up' => array ( 0 => 'ref.classobj.php', 1 => '类/对象 函数', ), 'prev' => array ( 0 => 'function.get-parent-class.php', 1 => 'get_parent_class', ), 'next' => array ( 0 => 'function.is-a.php', 1 => 'is_a', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/classobj/functions/interface-exists.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.0.2, PHP 7, PHP 8)
interface_exists — 检查接口是否已被定义
示例 #1 interface_exists() 示例
<?php
// 在尝试使用前先检查接口是否存在
if (interface_exists('MyInterface')) {
class MyClass implements MyInterface
{
// Methods
}
}
?>