ReflectionClass::getConstants

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getConstants獲取常量

說明

public ReflectionClass::getConstants(?int $filter = null): array

從類中獲取所有已定義的常量,而不管它們的可見性如何。

參數

filter

可選過濾器,傳入過濾所需的可見性常量。可用 ReflectionClassConstant 常量 進行配置,默認為所有可見性常量。

返回值

常量的數組,常量名是數組的鍵,常量的值是數組的值。

更新日志

版本 說明
8.0.0 添加 filter 。

參見