array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'function.interface-exists.php', 1 => 'interface_exists', ), 'up' => array ( 0 => 'ref.classobj.php', 1 => 'Classes/Object Functions', ), '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' => 'en', '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 — Checks if the interface has been defined
Checks if the given interface has been defined.
Example #1 interface_exists() example
<?php
// Check the interface exists before trying to use it
if (interface_exists('MyInterface')) {
class MyClass implements MyInterface
{
// Methods
}
}
?>