牛牛在线工具

class_implements()

收录 8868 个 PHP 函数,含用途说明与用法示例。

class_implements()

返回一个类实现的所有接口的数组

函数名:class_implements() 适用版本:5.0.2及以上版本 用法: class_implements() 函数用于返回一个类实现的所有接口的数组。 语法: array class_implements ( mixed $class [, bool $autoload = TRUE ] ) 参数: $class:要检查的对象或类名。 $autoload:一个可选的布尔值参数,指定在找不到类时是否自动加载。默认为 true。 返回值: 成功时返回一个包含类实现的所有接口的数组,失败时返回 false。 示例: interface MyInterface { public function hello(); } class MyClass implements MyInterface { public function hello() { echo "Hello World!"; } } $interfaces = class_implements('MyClass'); print_r($interfaces); 输出: Array ( [MyInterface] => MyInterface ) 上述示例中,MyClass 类实现了 MyInterface 接口。通过调用 class_implements() 函数,我们得到了一个包含类实现的接口的数组 ["MyInterface" => "MyInterface"]。