array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.get-declared-classes.php', 1 => 'get_declared_classes', ), 'up' => array ( 0 => 'ref.classobj.php', 1 => '类/对象 函数', ), 'prev' => array ( 0 => 'function.get-class.php', 1 => 'get_class', ), 'next' => array ( 0 => 'function.get-declared-interfaces.php', 1 => 'get_declared_interfaces', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/classobj/functions/get-declared-classes.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
get_declared_classes — 返回由已定义类的名字所组成的数组
此函数没有参数。
返回由当前脚本中已定义类的名字组成的数组。
注意:
需要注意的是额外类的出现依赖于你已编译到 PHP 中的库。这意味着你不能使用这些类名定义自己的类。在附录的 预定义类 部分有预定义类的列表。
版本 | 说明 |
---|---|
7.4.0 | 之前 get_declared_classes() 返回的顺序总是父类在前,子类在后。现在不会这样了。get_declared_classes() 的返回值将不再保证顺序。 |
示例 #1 get_declared_classes() 示例
<?php
print_r(get_declared_classes());
?>
以上示例的输出类似于:
Array ( [0] => stdClass [1] => __PHP_Incomplete_Class [2] => Directory )