get_declared_classes()函数是PHP中的内置函数,用于返回具有已定义类名称的数组。用户数组,其中包含当前脚本中所有system-defined(例如PDO,XML阅读器等)的列表以及用户定义的类。没有为该函数提供参数。
<?php
class gfg {
function add () {
$a = 9 + 2 ;
}
}
class gfg1 {
function tr() {
echo (4);
}
}
print_r(get_declared_classes());
?>
输出:
Array
(
[0] => stdClass
[1] => Exception
[2] => ErrorException
[3] => Error
[4] => ParseError
. . .
[155] => Ds\PriorityQueue
[156] => Ds\Pair
[157] => gfg
[158] => gfg1
)
排序列表:在如此庞大的清单中找到特定的课程可能很困难。但是,如果按字母顺序对列表进行排序会更容易。可以通过函数排序sort()。
<?php
$sorted = get_declared_classes();
sort($sorted);
print_r($sorted);
?>
输出:
Array
(
[0] => AppendIterator
[1] => ArithmeticError
[2] => ArrayIterator
[3] => ArrayObject
[4] => AssertionError
. . .
[152] => XMLWriter
[153] => __PHP_Incomplete_Class
[154] => finfo
[155] => php_user_filter
[156] => stdClass
)
参考: https://www.php.net/manual/en/function.get-declared-classes.php
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
相关用法
- d3.js d3.set.has()用法及代码示例
- PHP Ds\Set contains()用法及代码示例
- PHP Ds\Set last()用法及代码示例
- PHP Ds\Set first()用法及代码示例
- p5.js hex()用法及代码示例
- p5.js arc()用法及代码示例
- PHP dir()用法及代码示例
- p5.js box()用法及代码示例
- d3.js d3.mean()用法及代码示例
- d3.js d3.map.set()用法及代码示例
- PHP exp()用法及代码示例
- PHP Ds\Map first()用法及代码示例
- PHP Ds\Map sum()用法及代码示例
- PHP pi( )用法及代码示例
- PHP Ds\Map get()用法及代码示例
- d3.js d3.min()用法及代码示例
注:本文由纯净天空筛选整理自sayesha大神的英文原创作品 PHP | get_declared_classes() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
