©
本文档使用
php中文网手册 发布
(PHP 5 >= 5.1.0)
ReflectionClass::hasConstant — 检查常量是否已经定义
$name
)检查类中是否已经定义了指定的常量。
name 要被检查的常量名称。
如果已定义返回 TRUE ,否则返回 FALSE 。
Example #1 ReflectionClass::hasConstant() 例子
<?php
class Foo {
const c1 = 1 ;
}
$class = new ReflectionClass ( "Foo" );
var_dump ( $class -> hasConstant ( "c1" ));
var_dump ( $class -> hasConstant ( "c2" ));
?> 以上例程的输出类似于:
bool(true) bool(false)