使用PHP获取某个类中的全部常量
最近使用php ZipArchive类时,遇到文档不够详细,常量说明不够具体的情况。
于是查询度娘以后得到了以下解决方案:
$objClass = new \ReflectionClass(ZipArchive);
$arrConst = $objClass->getConstants();
print_r($arrConst);exit;
除了常量,还有很多可以获取的,参考Reflection文档:
https://www.php.net/manual/zh/book.reflection.php
- 上一篇: thinkphp5在cli模式下日志的bug
- 下一篇: 一些常用命令