array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'function.interface-exists.php', 1 => 'interface_exists', ), 'up' => array ( 0 => 'ref.classobj.php', 1 => 'Fonctions Classes/Objets', ), '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' => 'fr', '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 — Vérifie si une interface a été définie
Vérifie si une interface a été définie.
interface
Le nom de l'interface
autoload
Si l'on doit appeler autoload ou non par défaut.
Retourne true
si l'interface fournie par le paramètre
interface
a été définie,
false
sinon.
Exemple #1 Exemple avec interface_exists()
<?php
// Vérifie si l'interface existe avant de l'utiliser
if (interface_exists('MyInterface')) {
class MyClass implements MyInterface
{
// Méthodes
}
}
?>