2015年5月7日 星期四

getConstants

php中反射(ReflectionClass)的語法


如果想要取得物件中取得const的陣列可以使用



    const STATE0 = 'open';
    const STATE1 = 'close';
    const STATE2 = 'run1';
    const STATE3 = 'run2';
    const STATE4 = 'run3';
   
    static function getConstants() {
        $oClass = new ReflectionClass(__CLASS__);
        return $oClass->getConstants();
    }