ReflectionExtension::getClasses()函数是PHP中的内置函数,用于从指定的扩展名返回类列表。如果未指定任何类,则返回一个空数组。
用法:
array ReflectionExtension::getClasses( void )
参数:该函数不接受任何参数。
返回值:此函数返回指定扩展名中的类的列表。
以下示例程序旨在说明PHP中的ReflectionExtension::getClasses()函数:
程序_1:
<?php
// Defining an extension
$A = 'DOM';
// Using ReflectionExtension() over the
// specified extension
$extension = new ReflectionExtension($A);
// Calling the getClasses() function
$B = $extension->getClasses();
// Getting the list of classes
var_dump($B);
?>
输出:
array(31) { ["DOMException"]=> object(ReflectionClass)#2 (1) { ["name"]=> string(12) "DOMException" } ["DOMStringList"]=> object(ReflectionClass)#3 (1) { ["name"]=> string(13) "DOMStringList" } ["DOMNameList"]=> object(ReflectionClass)#4 (1) { ["name"]=> string(11) "DOMNameList" } ["DOMImplementationList"]=> object(ReflectionClass)#5 (1) { ["name"]=> string(21) "DOMImplementationList" } ["DOMImplementationSource"]=> object(ReflectionClass)#6 (1) { ["name"]=> string(23) "DOMImplementationSource" } ["DOMImplementation"]=> object(ReflectionClass)#7 (1) { ["name"]=> string(17) "DOMImplementation" } ["DOMNode"]=> object(ReflectionClass)#8 (1) { ["name"]=> string(7) "DOMNode" } ["DOMNameSpaceNode"]=> object(ReflectionClass)#9 (1) { ["name"]=> string(16) "DOMNameSpaceNode" } ["DOMDocumentFragment"]=> object(ReflectionClass)#10 (1) { ["name"]=> string(19) "DOMDocumentFragment" } ["DOMDocument"]=> object(ReflectionClass)#11 (1) { ["name"]=> string(11) "DOMDocument" } ["DOMNodeList"]=> object(ReflectionClass)#12 (1) { ["name"]=> string(11) "DOMNodeList" } ["DOMNamedNodeMap"]=> object(ReflectionClass)#13 (1) { ["name"]=> string(15) "DOMNamedNodeMap" } ["DOMCharacterData"]=> object(ReflectionClass)#14 (1) { ["name"]=> string(16) "DOMCharacterData" } ["DOMAttr"]=> object(ReflectionClass)#15 (1) { ["name"]=> string(7) "DOMAttr" } ["DOMElement"]=> object(ReflectionClass)#16 (1) { ["name"]=> string(10) "DOMElement" } ["DOMText"]=> object(ReflectionClass)#17 (1) { ["name"]=> string(7) "DOMText" } ["DOMComment"]=> object(ReflectionClass)#18 (1) { ["name"]=> string(10) "DOMComment" } ["DOMTypeinfo"]=> object(ReflectionClass)#19 (1) { ["name"]=> string(11) "DOMTypeinfo" } ["DOMUserDataHandler"]=> object(ReflectionClass)#20 (1) { ["name"]=> string(18) "DOMUserDataHandler" } ["DOMDomError"]=> object(ReflectionClass)#21 (1) { ["name"]=> string(11) "DOMDomError" } ["DOMErrorHandler"]=> object(ReflectionClass)#22 (1) { ["name"]=> string(15) "DOMErrorHandler" } ["DOMLocator"]=> object(ReflectionClass)#23 (1) { ["name"]=> string(10) "DOMLocator" } ["DOMConfiguration"]=> object(ReflectionClass)#24 (1) { ["name"]=> string(16) "DOMConfiguration" } ["DOMCdataSection"]=> object(ReflectionClass)#25 (1) { ["name"]=> string(15) "DOMCdataSection" } ["DOMDocumentType"]=> object(ReflectionClass)#26 (1) { ["name"]=> string(15) "DOMDocumentType" } ["DOMNotation"]=> object(ReflectionClass)#27 (1) { ["name"]=> string(11) "DOMNotation" } ["DOMEntity"]=> object(ReflectionClass)#28 (1) { ["name"]=> string(9) "DOMEntity" } ["DOMEntityReference"]=> object(ReflectionClass)#29 (1) { ["name"]=> string(18) "DOMEntityReference" } ["DOMProcessingInstruction"]=> object(ReflectionClass)#30 (1) { ["name"]=> string(24) "DOMProcessingInstruction" } ["DOMStringExtend"]=> object(ReflectionClass)#31 (1) { ["name"]=> string(15) "DOMStringExtend" } ["DOMXPath"]=> object(ReflectionClass)#32 (1) { ["name"]=> string(8) "DOMXPath" } }
程序_2:
<?php
// Using ReflectionExtension() over
// a extension xml
$extension = new ReflectionExtension('xml');
// Calling the getClasses() function and
// Getting the list of classes
var_dump($extension->getClasses());
?>
输出:
array(0) { }
参考: https://www.php.net/manual/en/reflectionextension.getclasses.php
相关用法
- PHP ReflectionExtension getName()用法及代码示例
- PHP ReflectionExtension getDependencies()用法及代码示例
- PHP ReflectionExtension getINIEntries()用法及代码示例
- PHP ReflectionExtension getVersion()用法及代码示例
- PHP ReflectionExtension isPersistent()用法及代码示例
- PHP ReflectionExtension export()用法及代码示例
- PHP ReflectionExtension __toString()用法及代码示例
- PHP ReflectionExtension info()用法及代码示例
- PHP ReflectionExtension getFunctions()用法及代码示例
- PHP ReflectionExtension isTemporary()用法及代码示例
- PHP ReflectionExtension getConstants()用法及代码示例
- PHP ReflectionExtension getClassNames()用法及代码示例
注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 PHP | ReflectionExtension getClasses() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。