English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP reference manual

PHP interface_exists() function usage and example

PHP Class/Object function reference manual

The interface_exists() function checks if the interface has been defined

Syntax

interface_exists( $interface_name[, $autoload]);

Definition and usage

This function checks if the given interface is already defined.

Parameter

Serial numberParameters and descriptions
1

interface_name(Required)

Interface name

2

autoload(Optional)

Default whether to call __autoload.

Return value

 This function returns TRUE if the interface defined by interface_name is already defined, otherwise it returns FALSE.

Online examples

Here is the usage of this function-

<?php
    // Check if the interface exists before trying to use it
   if (interface_exists('SomeInterface')) {
      class MyClass implements SomeInterface {
         // Method
      }
   }
?>

 PHP Class/Object function reference manual