如何在 PHP 类中检查常量是否已定义?
class Foo {
const BAR = 1;
}
是否有类似于property_exists()
或者method_exists()
的方法可以判断类常量是否存在?还是我可以直接使用defined("Foo::BAR")
?