ReflectionClass::hasConstant

(PHP 5 >= 5.1.2, PHP 7)

ReflectionClass::hasConstant锟斤拷槌o拷锟斤拷欠锟斤拷丫锟斤拷锟斤拷锟�

说锟斤拷

public ReflectionClass::hasConstant ( string $name ) : bool

锟斤拷锟斤拷锟斤拷锟斤拷欠锟斤拷丫锟斤拷锟斤拷锟斤拷锟街革拷锟斤拷某锟斤拷锟斤拷锟�

锟斤拷锟斤拷

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)

锟轿硷拷