PHP get_declared_classes() 函数返回一个数组,其中包含所有声明的类的名称。
语法
get_declared_classes()
参数
不需要参数。
返回值
返回当前脚本中声明的类的名称数组。
示例:get_declared_classes() 示例
下面的示例显示了 get_declared_classes() 函数的用法。
<?php
class myClass {
//代码
}
print_r(get_declared_classes());
?>
上述代码的输出将类似于:
Array
(
[0] => stdClass
[1] => InternalIterator
[2] => Exception
[3] => ErrorException
[4] => Error
[5] => CompileError
[6] => ParseError
[7] => TypeError
[8] => ArgumentCountError
[9] => ValueError
[10] => ArithmeticError
[11] => DivisionByZeroError
[12] => UnhandledMatchError
[13] => Closure
[14] => Generator
[15] => ClosedGeneratorException
[16] => WeakReference
[17] => WeakMap
[18] => Attribute
[19] => DateTime
[20] => DateTimeImmutable
[21] => DateTimeZone
[22] => DateInterval
[23] => DatePeriod
[24] => LibXMLError
[25] => OpenSSLCertificate
[26] => OpenSSLCertificateSigningRequest
[27] => OpenSSLAsymmetricKey
[28] => InflateContext
[29] => DeflateContext
[30] => HashContext
[31] => JsonException
[32] => ReflectionException
[33] => Reflection
[34] => ReflectionFunctionAbstract
[35] => ReflectionFunction
[36] => ReflectionGenerator
[37] => ReflectionParameter
[38] => ReflectionType
[39] => ReflectionNamedType
[40] => ReflectionUnionType
[41] => ReflectionMethod
[42] => ReflectionClass
[43] => ReflectionObject
[44] => ReflectionProperty
[45] => ReflectionClassConstant
[46] => ReflectionExtension
[47] => ReflectionZendExtension
[48] => ReflectionReference
[49] => ReflectionAttribute
[50] => LogicException
[51] => BadFunctionCallException
[52] => BadMethodCallException
[53] => DomainException
[54] => InvalidArgumentException
[55] => LengthException
[56] => OutOfRangeException
[57] => RuntimeException
[58] => OutOfBoundsException
[59] => OverflowException
[60] => RangeException
[61] => UnderflowException
[62] => UnexpectedValueException
[63] => RecursiveIteratorIterator
[64] => IteratorIterator
[65] => FilterIterator
[66] => RecursiveFilterIterator
[67] => CallbackFilterIterator
[68] => RecursiveCallbackFilterIterator
[69] => ParentIterator
[70] => LimitIterator
[71] => CachingIterator
[72] => RecursiveCachingIterator
[73] => NoRewindIterator
[74] => AppendIterator
[75] => InfiniteIterator
[76] => RegexIterator
[77] => RecursiveRegexIterator
[78] => EmptyIterator
[79] => RecursiveTreeIterator
[80] => ArrayObject
[81] => ArrayIterator
[82] => RecursiveArrayIterator
[83] => SplFileInfo
[84] => DirectoryIterator
[85] => FilesystemIterator
[86] => RecursiveDirectoryIterator
[87] => GlobIterator
[88] => SplFileObject
[89] => SplTempFileObject
[90] => SplDoublyLinkedList
[91] => SplQueue
[92] => SplStack
[93] => SplHeap
[94] => SplMinHeap
[95] => SplMaxHeap
[96] => SplPriorityQueue
[97] => SplFixedArray
[98] => SplObjectStorage
[99] => MultipleIterator
[100] => SessionHandler
[101] => __PHP_Incomplete_Class
[102] => php_user_filter
[103] => Directory
[104] => AssertionError
[105] => SodiumException
[106] => PDOException
[107] => PDO
[108] => PDOStatement
[109] => PDORow
[110] => XMLParser
[111] => DOMException
[112] => DOMImplementation
[113] => DOMNode
[114] => DOMNameSpaceNode
[115] => DOMDocumentFragment
[116] => DOMDocument
[117] => DOMNodeList
[118] => DOMNamedNodeMap
[119] => DOMCharacterData
[120] => DOMAttr
[121] => DOMElement
[122] => DOMText
[123] => DOMComment
[124] => DOMCdataSection
[125] => DOMDocumentType
[126] => DOMNotation
[127] => DOMEntity
[128] => DOMEntityReference
[129] => DOMProcessingInstruction
[130] => DOMXPath
[131] => FFI\Exception
[132] => FFI\ParserException
[133] => FFI
[134] => FFI\CData
[135] => FFI\CType
[136] => finfo
[137] => PharException
[138] => Phar
[139] => PharData
[140] => PharFileInfo
[141] => Shmop
[142] => SimpleXMLElement
[143] => SimpleXMLIterator
[144] => Socket
[145] => AddressInfo
[146] => SysvMessageQueue
[147] => SysvSemaphore
[148] => SysvSharedMemory
[149] => PhpToken
[150] => XMLReader
[151] => XMLWriter
[152] => XSLTProcessor
[153] => myClass
)