ReflectionClass::getInterfaces()函數是PHP中的一個內置函數,用於返回接口的關聯數組。這些返回的數組包含作為接口名稱的鍵和作為ReflectionClass對象的數組值。
用法:
array ReflectionClass::getInterfaces( void )
參數:該函數不接受任何參數。
返回值:此函數返回接口的關聯數組。這些返回的數組包含作為接口名稱的鍵和作為ReflectionClass對象的數組值。
以下示例程序旨在說明PHP中的ReflectionClass::getInterfaces()函數:
示例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);
?>
輸出:
Array ( [Colleges] => ReflectionClass Object ( [name] => Colleges ) [Departments] => ReflectionClass Object ( [name] => Departments ) [Students] => ReflectionClass Object ( [name] => Students ) [Companies] => ReflectionClass Object ( [name] => Companies ) )
示例2:
<?php
// Using ReflectionClass
$ReflectionClass = new ReflectionClass('ReflectionClass');
// Calling getInterfaces() functions
$A = $ReflectionClass->getInterfaces();
// Getting the associative array of interfaces
var_dump($A);
?>
輸出:
array(1) { ["Reflector"]=> object(ReflectionClass)#2 (1) { ["name"]=> string(9) "Reflector" } }
參考: https://www.php.net/manual/en/reflectionclass.getinterfaces.php
相關用法
- PHP ReflectionClass getExtensionName()用法及代碼示例
- PHP ReflectionClass isTrait()用法及代碼示例
- PHP ReflectionClass isUserDefined()用法及代碼示例
- PHP ReflectionClass getFileName()用法及代碼示例
- PHP ReflectionClass getConstants()用法及代碼示例
- PHP ReflectionClass getParentClass()用法及代碼示例
- PHP ReflectionClass isIterateable()用法及代碼示例
- PHP ReflectionClass getExtension()用法及代碼示例
- PHP ReflectionClass getStartLine()用法及代碼示例
- PHP ReflectionClass isSubclassOf()用法及代碼示例
- PHP ReflectionClass hasConstant()用法及代碼示例
- PHP ReflectionClass hasProperty()用法及代碼示例
- PHP ReflectionClass isInternal()用法及代碼示例
- PHP ReflectionClass isInterface()用法及代碼示例
- PHP ReflectionClass getConstructor()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 PHP | ReflectionClass getInterfaces() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。