interface_exists

interface_exists

(PHP 5 >= 5.0.2, PHP 7)

interface_existsChecks if the interface has been defined

Description

bool interface_exists ( string $interface_name [, bool $autoload = true ] )

Checks if the given interface has been defined.

Parameters

interface_name

The interface name

autoload

Whether to call __autoload or not by default.

Return Values

Returns TRUE if the interface given by interface_name has been defined, FALSE otherwise.

Examples

Example #1 interface_exists() example

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

?>

See Also

© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/function.interface-exists.php

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部