array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'it', ), 'this' => array ( 0 => 'function.interface-exists.php', 1 => 'interface_exists', 2 => 'Checks if the interface has been defined', ), 'up' => array ( 0 => 'ref.classobj.php', 1 => 'Classes/Object Funzioni', ), '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', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($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.
interfaceThe interface name
autoloadWhether to autoload if not already loaded.
Returns true if the interface given by
interface has been defined, false otherwise.
Example #1 interface_exists() example
<?php
// Check the interface exists before trying to use it
if (interface_exists('MyInterface')) {
class MyClass implements MyInterface
{
// Methods
}
}
?>