Open In App

PHP | ReflectionExtension getClassNames() Function

Last Updated : 11 Dec, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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
  
// Defining an extension
$A = 'DOM';
  
// Using ReflectionExtension() over the 
// specified extension
$extension = new ReflectionExtension($A);
  
// Calling the getClassNames() function
$B = $extension->getClassNames();
  
// Getting an array of class name
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
  
// Using ReflectionExtension() over 
// a extension xml
$extension = new ReflectionExtension('xml');
  
// Calling the getClassNames() function and
// Getting an array of class names
var_dump($extension->getClassNames());
?>


Output:

array(0) {
}

Reference: https://www.php.net/manual/en/reflectionextension.getclassnames.php



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads