class_uses Return the traits used by the given class
发表日期:2021-07-01 08:56:25 | 来源: | | 浏览(1286) 分类:SPL 函数
class_uses
(PHP 5 >= 5.4.0, PHP 7, PHP 8)
class_uses — Return the traits used by the given class
说明
class_uses(mixed
$class, bool $autoload = true): array
This function returns an array with the names of the traits that the
given class uses. This does however not include
any traits used by a parent class.
参数
-
class -
An object (class instance) or a string (class name).
-
autoload -
Whether to allow this function to load the class automatically through the __autoload() magic method.
返回值
An array on success, or false on error.
范例
示例 #1 class_uses() example
<?php
trait foo {
}
class bar {
use foo;
}
print_r(class_uses(new bar));
print_r(class_uses('bar'));
function __autoload($class_name) {
require_once $class_name . '.php';
}
// use __autoload to load the 'not_loaded' classprint_r(class_uses('not_loaded', true));
?>
以上例程的输出类似于:
Array
(
[foo] => foo
)
Array
(
[foo] => foo
)
Array
(
[trait_of_not_loaded] => trait_of_not_loaded
)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- class_implements 返回指定的类实现的所有接口。(0)
- class_parents 返回指定类的父类。(0)
- class_uses Return the traits used by the given class(0)
- iterator_apply 为迭代器中每个元素调用一个用户自定义函数(0)
- iterator_count 计算迭代器中元素的个数(0)
- iterator_to_array 将迭代器中的元素拷贝到数组(0)
- spl_autoload_call 尝试调用所有已注册的 __autoload() 函数来装载请求类(0)
- spl_autoload_extensions 注册并返回 spl_autoload 函数使用的默认文件扩展名(0)
- spl_autoload_functions 返回所有已注册的 __autoload() 函数(0)
- spl_autoload_register 注册给定的函数作为 __autoload 的实现(0)
- spl_autoload_unregister 注销已注册的 __autoload() 函数(0)
- spl_autoload __autoload()函数的默认实现(0)
- spl_classes 返回所有可用的SPL类(0)
- spl_object_hash 返回指定对象的hash id(0)
- spl_object_id Return the integer object handle for given object(0)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
宁公网安备 64010402001209号