(PHP 5, PHP 7, PHP 8)
ReflectionClass::getConstant — 獲取已定義的常量
獲取已定義的常量。
本函數(shù)還未編寫(xiě)文檔,僅有參數(shù)列表。
name要獲取的類(lèi)常量的名稱(chēng)。
常量名稱(chēng)為 name 的值。
如果在類(lèi)中沒(méi)有找到該常量,則返回 false 。
示例 #1 使用 ReflectionClass::getConstant()
<?php
class Example {
const C1 = false;
const C2 = 'I am a constant';
}
$reflection = new ReflectionClass('Example');
var_dump($reflection->getConstant('C1'));
var_dump($reflection->getConstant('C2'));
var_dump($reflection->getConstant('C3'));
?>
以上例程會(huì)輸出:
bool(false) string(15) "I am a constant" bool(false)