Classes/Object 函数
PHP Manual

get_declared_classes

(PHP 4, PHP 5)

get_declared_classes返回由已定义类的名字所组成的数组

说明

array get_declared_classes ( void )

返回由当前脚本中已定义类的名字组成的数组。

Note:

在 PHP 4.0.1pl2 中,有三个额外的类存在于返回的数组中:stdClass(在 Zend/zend.c 中定义)、OverloadedTestClass(在 ext/standard/basic_functions.c 中定义)和 Directory(在 ext/standard/dir.c 中定义)。

还需要注意的是额外类的出现依赖于你已编译到 PHP 中的库。这意味着你不能使用这些类名定义自己的类。在附录的 预定义类 部分有预定义类的列表。

Example #1 get_declared_classes() 例子

<?php
print_r
(get_declared_classes());
?>

以上例程的输出类似于:

Array
(
    [0] => stdClass
    [1] => __PHP_Incomplete_Class
    [2] => Directory
)

参见 class_exists()get_declared_interfaces()

返回值

Returns an array of the names of the declared classes in the current script.

Note:

Note that depending on what extensions you have compiled or loaded into PHP, additional classes could be present. This means that you will not be able to define your own classes using these names. There is a list of predefined classes in the Predefined Classes section of the appendices.

范例

Example #2 get_declared_classes() example

<?php
print_r
(get_declared_classes());
?>

以上例程的输出类似于:

Array
(
    [0] => stdClass
    [1] => __PHP_Incomplete_Class
    [2] => Directory
)

参见


Classes/Object 函数
PHP Manual