PHP | ReflectionExtension getClassNames() Function
Last Updated :
11 Dec, 2019
The ReflectionExtension::getClassNames() function is an inbuilt function in PHP which is used to return an array of class names from the specified extension. If no classes are specified, an empty array is returned.
Syntax:
array ReflectionExtension::getClassNames( void )
Parameters: This function does not accept any parameter.
Return Value: This function returns an array of class names from the specified extension.
Below programs illustrate the ReflectionExtension::getClassNames() function in PHP:
Program_1:
<?php
$A = 'DOM' ;
$extension = new ReflectionExtension( $A );
$B = $extension ->getClassNames();
var_dump( $B );
?>
|
Output:
array(31) {
[0]=>
string(12) "DOMException"
[1]=>
string(13) "DOMStringList"
[2]=>
string(11) "DOMNameList"
[3]=>
string(21) "DOMImplementationList"
[4]=>
string(23) "DOMImplementationSource"
[5]=>
string(17) "DOMImplementation"
[6]=>
string(7) "DOMNode"
[7]=>
string(16) "DOMNameSpaceNode"
[8]=>
string(19) "DOMDocumentFragment"
[9]=>
string(11) "DOMDocument"
[10]=>
string(11) "DOMNodeList"
[11]=>
string(15) "DOMNamedNodeMap"
[12]=>
string(16) "DOMCharacterData"
[13]=>
string(7) "DOMAttr"
[14]=>
string(10) "DOMElement"
[15]=>
string(7) "DOMText"
[16]=>
string(10) "DOMComment"
[17]=>
string(11) "DOMTypeinfo"
[18]=>
string(18) "DOMUserDataHandler"
[19]=>
string(11) "DOMDomError"
[20]=>
string(15) "DOMErrorHandler"
[21]=>
string(10) "DOMLocator"
[22]=>
string(16) "DOMConfiguration"
[23]=>
string(15) "DOMCdataSection"
[24]=>
string(15) "DOMDocumentType"
[25]=>
string(11) "DOMNotation"
[26]=>
string(9) "DOMEntity"
[27]=>
string(18) "DOMEntityReference"
[28]=>
string(24) "DOMProcessingInstruction"
[29]=>
string(15) "DOMStringExtend"
[30]=>
string(8) "DOMXPath"
}
Program_2:
<?php
$extension = new ReflectionExtension( 'xml' );
var_dump( $extension ->getClassNames());
?>
|
Reference: https://www.php.net/manual/en/reflectionextension.getclassnames.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...