PHP | ReflectionClass getInterfaces() Function
The ReflectionClass::getInterfaces() function is an inbuilt function in PHP which is used to return an associative array of interfaces. These returned array is containing keys as interface names and the array values as ReflectionClass objects.
Syntax:
array ReflectionClass::getInterfaces( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns an associative array of interfaces. These returned array is containing keys as interface names and the array values as ReflectionClass objects.
Below programs illustrate the ReflectionClass::getInterfaces() function in PHP:
Program 1:
<?php // Defining some interfaces interface Colleges { } interface Departments { } interface Students { } interface Companies { } // Initialising a class of Interfaces class Interfaces implements Colleges, Departments, Students, Companies { } // Using ReflectionClass over the class Interfaces $A = new ReflectionClass("Interfaces"); // Calling the getInterfaces() function $B = $A->getInterfaces(); // Getting the associative array of interfaces print_r($B); ?> |
Output:
Array
(
[Colleges] => ReflectionClass Object
(
[name] => Colleges
)
[Departments] => ReflectionClass Object
(
[name] => Departments
)
[Students] => ReflectionClass Object
(
[name] => Students
)
[Companies] => ReflectionClass Object
(
[name] => Companies
)
)
Program 2:
<?php // Using ReflectionClass $ReflectionClass = new ReflectionClass('ReflectionClass'); // Calling getInterfaces() functions $A = $ReflectionClass->getInterfaces(); // Getting the associative array of interfaces var_dump($A); ?> |
Output:
array(1) {
["Reflector"]=>
object(ReflectionClass)#2 (1) {
["name"]=>
string(9) "Reflector"
}
}
Reference: https://www.php.net/manual/en/reflectionclass.getinterfaces.php
Recommended Posts:
- PHP | ReflectionClass getParentClass() Function
- PHP | ReflectionClass getConstants() Function
- PHP | ReflectionClass getConstant() Function
- PHP | ReflectionClass isSubclassOf() Function
- PHP | ReflectionClass isTrait() Function
- PHP | ReflectionClass isUserDefined() Function
- PHP | ReflectionClass isIterateable() Function
- PHP | ReflectionClass isCloneable() Function
- PHP | ReflectionClass hasProperty() Function
- PHP | ReflectionClass isAbstract() Function
- PHP | ReflectionClass isAnonymous() Function
- PHP | ReflectionClass getConstructor() Function
- PHP | ReflectionClass getReflectionConstants() Function
- PHP | ReflectionClass isInstance() Function
- PHP | ReflectionClass export() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


