ReflectionClass::getInterfaceNames()函數是PHP中的內置函數,用於返回接口名稱數組作為值。
用法:
array ReflectionClass::getInterfaceNames( void )
參數:該函數不接受任何參數。
返回值:此函數返回接口名稱數組作為值。
以下示例程序旨在說明PHP中的ReflectionClass::getInterfaceNames()函數:
示例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 getInterfaceNames() function
$B = $A->getInterfaceNames();
// Getting the name of the specified Interfaces
print_r($B);
?>
輸出:
Array ( [0] => Colleges [1] => Departments [2] => Students [3] => Companies )
示例2:
<?php
// Using ReflectionClass
$ReflectionClass = new ReflectionClass('ReflectionClass');
// Calling getInterfaceNames() functions
$A = $ReflectionClass->getInterfaceNames();
// Getting the name of the interfaces
var_dump($A);
?>
輸出:
array(1) { [0]=> string(9) "Reflector" }
參考: https://www.php.net/manual/en/reflectionclass.getinterfacenames.php
相關用法
- PHP ReflectionClass isIterateable()用法及代碼示例
- PHP ReflectionClass isUserDefined()用法及代碼示例
- PHP ReflectionClass isTrait()用法及代碼示例
- PHP ReflectionClass getProperties()用法及代碼示例
- PHP ReflectionClass getProperty()用法及代碼示例
- PHP ReflectionClass getMethod()用法及代碼示例
- PHP ReflectionClass isSubclassOf()用法及代碼示例
- PHP ReflectionClass getDefaultProperties()用法及代碼示例
- PHP ReflectionClass hasConstant()用法及代碼示例
- PHP ReflectionClass getStartLine()用法及代碼示例
- PHP ReflectionClass isAnonymous()用法及代碼示例
- PHP ReflectionClass isAbstract()用法及代碼示例
- PHP ReflectionClass implementsInterface()用法及代碼示例
- PHP ReflectionClass getConstant()用法及代碼示例
- PHP ReflectionClass getExtension()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 PHP | ReflectionClass getInterfaceNames() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。